26 #include <bias_config.h>
28 #ifndef BIAS_HAVE_XML2
29 # error You need XML2 to compile this code. Please enable USE_XML2 and recompile BIAS.
30 #endif // BIAS_HAVE_XML2
33 #include <Image/ProjectionMapping.hh>
34 #include <Geometry/Projection.hh>
35 #include <Geometry/ProjectionParametersPerspective.hh>
36 #include <Geometry/ProjectionParametersSpherical.hh>
37 #include <Base/Image/ImageIO.hh>
38 #include <Base/Image/ImageConvert.hh>
39 #include <Utils/Param.hh>
56 int main(
int argc,
char** argv )
62 "Absolute path to the source Image",
67 "Absolute path to the sink Image",
68 "image_projection_trilinear",
72 "Absolute path to the source Camera calibration XML",
76 "Absolute path to the sink Camera calibration XML",
80 bool* rescaleSourceCamToImageSize = param->
AddParamBool(
"RescaleCam",
81 "Should source cam be scaled to fit image size?",
95 int ret = source_proj.
XMLRead(*sourceCam);
97 BIASERR(
"Error reading Projection:"<<*sourceCam)
100 else cout<<"Read source projection:"<<sourceCam<<endl;
103 ret = sink_proj.XMLRead(*sinkCam);
105 BIASERR(
"Error reading Projection:"<<*sinkCam)
108 else cout<<"Read sink projection:"<<sinkCam<<endl;
116 Image<
unsigned char> source;
117 Image<
unsigned char> sink;
118 if (
ImageIO::Load(*sourceImg, source)!=0){
119 BIASERR(
"error loading image "<< *sourceImg)
122 if(source.GetColorModel() !=
ImageBase::CM_RGB){
123 cout<<
"Converting to RGB:"<<endl;
128 cout<<
"Colormodel is RGB:"<<endl;
132 if(*rescaleSourceCamToImageSize){
133 unsigned int width = source.GetWidth();
134 unsigned int height = source.GetHeight();
145 sink.Init(source.GetWidth(),source.GetHeight(),source.GetChannelCount());
153 disp.
Init(source.GetWidth(),source.GetHeight(),3);
Routines for loading and writing all kinds of image formats.
int XMLRead(const std::string &Filename)
derived classes must implement the function XMLIn which is called by this function XMLRead to read ev...
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()
virtual void Rescale(double ratio, const double offset=0.0)
Adapt internal parameters to resampled image.
bool * AddParamBool(const std::string &name, const std::string &help, bool deflt=false, char cmdshort=0, int Group=GRP_NOSHOW)
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
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 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.
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
This class Param provides generic support for parameters.
int GetDisplacementMap(Image< float > &dismap, int width, int height)
precomputes lookup coordinates and computes displacement map int TEXTURE coordinates, according to the size of src (or width,height)
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
This is the base class for images in BIAS.
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)
static int ToRGB(const Image< StorageType > &source, Image< StorageType > &dest)
Create a RGB converted copy of source image in this.