30 #include <Geometry/PMatrix.hh>
31 #include <Geometry/Projection.hh>
32 #include <Geometry/ProjectionParametersPerspective.hh>
33 #include <Utils/Param.hh>
47 void usage(
char* name)
50 cout<<
"\nConverts PMatrix files into Projection readable files.\n";
53 cout<<name<<
"params <PMatrix> ...\n";
56 string GetBaseName(
const std::string& FileName)
58 int begin = FileName.find_last_of(
'/');
59 int end = FileName.find_last_of(
'.');
60 return FileName.substr(begin+1, end-begin-1);
64 void PtoPPP(
Projection &proj,
const string &file,
65 unsigned int w,
unsigned int h,
bool overwriteIntrinsics)
71 cout<<
"no perspective parameters?\n";
77 cout<<
"could not read "<<file<<endl;
81 BIASASSERT(static_cast<RMatrixBase>(P.
GetR()).GetQuaternion(quat)==0);
87 if (overwriteIntrinsics) {
92 proj.
XMLWrite(GetBaseName(file)+
".xml");
93 cout<<GetBaseName(file)+
".xml"<<endl;
94 #endif //BIAS_HAVE_XML2
101 int main(
int argc,
char* argv[])
106 string *CameraParamFile;
108 "width of corresponding image",
111 "height of corresponding image",
114 "file containing a list of pamtrices");
116 "XML-file with camera parameters");
127 std::vector< std::string > LinesInFile;
129 Param::ParseListFile (*listFile, LinesInFile);
130 cout<<
"found"<<LinesInFile.size()<<
"entries in specified listFile"<<endl;
133 bool UseKFromP =
false;
136 if (*CameraParamFile ==
"") {
137 cout<<
"width = "<<*width<<
" height = "<<*height<<endl;
144 #ifdef BIAS_HAVE_XML2
146 #endif //BIAS_HAVE_XML2
151 for(i=0; i<(int)LinesInFile.size(); i++) {
152 PtoPPP(*proj, LinesInFile[i], *width, *height, UseKFromP);
155 for(i=firstPMatrix; i<argc; i++) {
156 PtoPPP(*proj, argv[i], *width, *height, UseKFromP);
bool Load(const std::string &filename)
overload Load because it has to invalidate decomposition! JW 09/2003
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual void SetImageSize(const unsigned int w, const unsigned int h)
Set image dimensions (in pixels).
int GetR(Matrix3x3< double > &R)
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
virtual void SetQ(const BIAS::Quaternion< double > &Q)
Set orientation from unit quaternion Q.
void Usage(std::ostream &os=std::cout)
print Help-Information to stdout
const ProjectionParametersBase * GetParameters(unsigned int cam=0) const
const parameter access function
This class hides the underlying projection model, like projection matrix, spherical camera...
int XMLWrite(const std::string &Filename, int CompressionLevel=0, bool AutoAddCompressionSuffix=true, std::string encoding="UTF-8") const
call this to add the class to a new xml tree and write it to the file Filename.
int GetC(Vector3< double > &C)
computes translation vector origin world coo -> origin camera coo (center), uses decomposition, which is cached
This class Param provides generic support for parameters.
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
Implements a 3D rotation matrix.
describes a projective 3D -> 2D mapping in homogenous coordinates
virtual void SetK(const KMatrix &K)
sets the internal parameters from a given KMatrix and updates the cached K and its inverse ...
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)
virtual void SetC(const BIAS::Vector3< double > &C)
Set projection center.
int ReadFromCamParamFile(const std::string &filename, const bool silent=false)
Reads a camera data XML file and constructs the ProjectionParametersBase-pointer, using the Projectio...
int GetK(KMatrix &K)
calibration matrix