1 #include <Base/Image/Image.hh>
2 #include <Base/Image/ImageIO.hh>
3 #include <Geometry/Projection.hh>
4 #include <Geometry/ProjectionParametersPerspective.hh>
5 #include <Image/Camera.hh>
6 #include <Image/ProjectionMapping.hh>
7 #include <Utils/Param.hh>
20 int main(
int argc,
char *argv[])
22 cout <<
"\n---- biasUndistort ----\n";
26 bool *help = params.
AddParamBool(
"help",
"Show information about parameters.",
false,
'h');
27 std::string *srcFile = params.
AddParamString(
"input",
"Filename of input image (needed)",
"",
'i');
28 std::string *outFile = params.
AddParamString(
"output",
"Filename of output image (needed)",
"",
'o');
29 std::string *projFile = params.
AddParamString(
"proj",
"Filename of projection (optional)",
"",
'p');
32 if (*help || srcFile->empty() || outFile->empty()) {
40 cout <<
"[ERROR] Failed to load image from file " << *srcFile <<
"!\n\n";
47 if (!projFile->empty()) {
48 if (srcProj.
Load(*projFile) != 0) {
49 cout <<
"[ERROR] Failed to load projection from file " << *projFile <<
"!\n\n";
52 cout <<
"- Loaded projection from file " << *projFile <<
"\n";
56 cout <<
"- Read projection from image metadata\n";
58 cout <<
"[ERROR] Failed to read projection from image metadata!\n\n";
63 if (srcProj.
Size() != 1 || srcPPP == NULL) {
64 cout <<
"[ERROR] Invalid projection found! Supports only perspecive cameras!\n\n";
70 cout <<
"[ERROR] Image projection contains no distortion!\n\n";
75 unsigned int srcWidth, srcHeight;
79 cout <<
"[ERROR] Image and projection have different dimensions!\n\n";
97 cout <<
"- Creating undistorted image via backward mapping\n";
101 if (mapping.
Map(srcImage, outImage) != 0) {
102 cout <<
"[ERROR] Failed to undistort image via backward mapping!\n\n";
108 cout <<
"[ERROR] Failed to save image to file " << *outFile <<
"!\n\n";
110 cout <<
"- Saved undistorted image to file " << *outFile <<
"\n\n";
virtual int Load(const std::string &filename)
convenience wrapper which tries to read different formats
void SetDistortionType(BIAS_ProjParaPersp_DISTORTION_TYPE distype)
Set type of distortion parameters.
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
void SetSinkCam(const Projection &P, const Image< float > *sinkdepth=NULL)
Set your sink projection before calling Map(),.
void SetSourceCam(const Projection &P)
Set your source projection before calling Map()
bool * AddParamBool(const std::string &name, const std::string &help, bool deflt=false, char cmdshort=0, int Group=GRP_NOSHOW)
void SetUndistortion(double kc1, double kc2)
unsigned int GetWidth() const
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
void Usage(std::ostream &os=std::cout)
print Help-Information to stdout
void Clear(const StorageType value=0)
sets all pixels to zero/value
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 SetProj(const Projection &Proj)
unsigned int GetHeight() const
int Map(const Image< InputStorageType > &src, Image< OutputStorageType > &sink, InterpolationMethod=MapTrilinear, bool newSink=false, double SuperSampling=1.0)
backward mapping with various interpolations
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
virtual int GetImageSize(unsigned int &Width, unsigned int &Height) const
Obtain image dimensions.
int UpdateMetaData()
copy P_ and co.
This class Param provides generic support for parameters.
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
unsigned int Size() const
Determine number of ProjectionParameterBase pointers in Projection.
const BIAS::Projection & GetProj() const
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)
int ParseMetaData(bool bUse2x64bitTS=true)
After ImageIO::Load() operated on AppData_, this method fills P_, Timestamp, DC_*, ...