33 #include <Image/ProjectionMapping.hh>
34 #include <Base/Image/ImageIO.hh>
35 #include <Base/Image/ImageConvert.hh>
36 #include <Base/Image/Image.hh>
37 #include <Base/Debug/TimeMeasure.hh>
38 #include <Base/Math/Vector3.hh>
39 #include <Base/Math/Vector.hh>
40 #include <Utils/Param.hh>
41 #include <Utils/ThreeDOut.hh>
42 #include <Geometry/ProjectionParametersSpherical.hh>
43 #include <Image/Camera.hh>
50 void GetSequenceAngle(
unsigned int & sequence ,
Projection p1,
51 Projection p2,
const bool yaxis,
double & rotationAngle)
53 unsigned int width1,height1,width2,height2;
54 double angle1, angle2,focalLength;
63 if(!yaxis) angle1 = 2*atan(width1/(2*focalLength));
64 else angle1 = 2*atan(height1/(2*focalLength));
68 cout<<
"Hat nicht geklappt. Kamera 1 ist weder Perspektivisch, noch Spherisch.";
76 if(!yaxis) angle2 = 2*atan(width2/(2*focalLength));
77 else angle2 = 2*atan(height2/(2*focalLength));
81 cout<<
"Hat nicht geklappt. Kamera 2 ist weder Perspektivisch, noch Spherisch.";
85 sequence =(
unsigned int)(angle1/angle2);
86 rotationAngle = angle2;
89 rotationAngle = (angle1-angle2)/((
double)sequence-1);
92 cout <<
"Abgedeckter Winkel: " << (rotationAngle*(sequence-1)*180/M_PI) <<
" Winkel der OriginalKamera: " << (angle1*180/M_PI) <<
" Winkel der ZielKamera: " << (angle2*180/M_PI) << endl;
114 int main(
int argc,
char *argv[])
118 string sourceImage,sourceCam,sinkCam;
119 unsigned int sequence;
121 double rotationAngle;
125 "Absolute path to the source Image",
130 "Absolute path to the sink Image",
131 "image_projection_trilinear",
135 "Absolute path to the source Camera calibration XML",
139 "Angle to rotate around v in RAD (e.g. 0.1)",
145 "Absolute path to the sink Camera calibration XML",
149 "A Vector to rotate (e.g. 0.0 1.0 0.0)",
153 "Give a number of images to create a sequence",
159 "Create a mosaic from Image?",
167 if(sourceImage ==
"" || sourceCam ==
"")
169 BIASERR(argv[0]<<
" -i<image-file> -c<SourceCamera-file>" <<
170 "-vaSs[Rotation-Vector Rotation-Angle] [Sequence] [SinkCamera-file]");
177 BIASERR(
"error loading "<<sourceImage);
185 if (p1.
XMLRead(sourceCam)!=0) {
187 BIASERR(
"Error reading "<<sourceCam);
197 GenerateProjection(p2);
201 BIASERR(
"Error reading "<<sinkCam);
209 rotationVector.
MultiplyIP(1.0/rotationVector.NormL2());
212 SetRotation(p2,v,rotationAngle);
213 cout << rotationVector.Length() << endl;
215 unsigned int width, height;
220 if(sequence > 1 && !mosaic)
222 GetSequenceAngle(sequence,p1,p2,
false,rotationAngle);
225 cout<<
"ROI of source image is "<<*im.
GetROI()
226 <<
" while image size is "<<width<<
" x "<<height<<endl;
231 cout<<
"timing ..."<<endl<<flush;
234 stringstream filename;
240 for(
unsigned int i=0;i<50;i++){
241 cout<<
"Run: "<<i<<
"/50"<<endl;
242 SetRotation(p2,v,(0.03*((
double)i-(49.0/2.0))));
250 sprintf(tmpStr,
"%03i", i);
251 filename <<
"/datapc/sieg/oniemann/data/images/find/find_image_"<<tmpStr<<
".mip";
254 BIASERR(
"error image");
260 for (
unsigned int i=0; i<sequence; i++) {
265 cout <<
"Run "<<i<<endl;
266 cout <<
"RotationAngle: " << rotationAngle*((double)i-(((
double)sequence-1)/2.0))*180/M_PI << endl;
267 SetRotation(p2,v,(rotationAngle*((
double)i-(((
double)sequence-1)/2.0))));
271 cout <<
"Angle: " << (rotationAngle*180/M_PI) << endl;
282 sprintf(tmpStr,
"%03i", i);
283 filename <<
"/datapc/sieg/oniemann/data/images/reference/reference_image_000_"<<tmpStr<<
".mip";
286 BIASERR(
"error image");
293 double rotationAngle2;
294 unsigned int sequence2;
300 GetSequenceAngle(sequence,p1,p2,
false,rotationAngle);
301 GetSequenceAngle(sequence2,p1,p2,
true,rotationAngle2);
303 for (
unsigned int j=0; j<sequence2; j++) {
304 R3=
RMatrix(v2, (rotationAngle2*((
double)j-(((
double)sequence2-1.0)/2.0))));
305 for (
unsigned int i=0; i<sequence; i++) {
307 R2=
RMatrix(v, (rotationAngle*((
double)i-(((
double)sequence-1.0)/2.0))));
310 R2=
RMatrix(v, (rotationAngle*((
double)i+0.5-(((
double)sequence-1.0)/2.0))));
313 cout <<
"Run " << i <<
" " << j <<endl;
327 sprintf(tmpStr,
"%03i_%03i", j, i);
328 filename <<
"/datapc/sieg/oniemann/data/images/reference/reference_image_"<<tmpStr<<
".mip";
331 BIASERR(
"error image");
340 cout <<
"Trilinear mapping took "
double * GetParamDouble(const std::string &name) const
int XMLRead(const std::string &Filename)
derived classes must implement the function XMLIn which is called by this function XMLRead to read ev...
virtual void SetR(const BIAS::RMatrix &R)
Set orientation from rotation matrix R.
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(),.
virtual void SetPrincipal(const double x, const double y)
Set principal point in pixels relative to top left corner, virtual overload to recalculate K_...
void SetSourceCam(const Projection &P)
Set your source projection before calling Map()
virtual void SetImageSize(const unsigned int w, const unsigned int h)
Set image dimensions (in pixels).
bool * AddParamBool(const std::string &name, const std::string &help, bool deflt=false, char cmdshort=0, int Group=GRP_NOSHOW)
double * AddParamDouble(const std::string &name, const std::string &help, double deflt=0.0, double min=-DBL_MAX, double max=DBL_MAX, char cmdshort=0, int Group=GRP_NOSHOW)
void SetPyramidSize(const int newsize)
sets pyramid size to pyramid and updates if neccessary
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
bool * GetParamBool(const std::string &name) const
const ProjectionParametersBase * GetParameters(unsigned int cam=0) const
const parameter access function
ROI * GetROI()
Returns a pointer to the roi object.
void Mult(const Vector3< T > &argvec, Vector3< T > &destvec) const
matrix - vector multiplicate this matrix with Vector3, storing the result in destvec calculates: dest...
This class hides the underlying projection model, like projection matrix, spherical camera...
std::string * GetParamString(const std::string &name) const
BIAS::Vector< double > * GetParamVecDbl(const std::string &name) const
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
int SetProj(const Projection &Proj)
void GetFocalLength(double &f) const
Get the current camera focal length.
int * GetParamInt(const std::string &name) const
int Map(const Image< InputStorageType > &src, Image< OutputStorageType > &sink, InterpolationMethod=MapTrilinear, bool newSink=false, double SuperSampling=1.0)
backward mapping with various interpolations
void FillImageWithConstValue(StorageType Value)
fill grey images
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.
class Vector3 contains a Vector of fixed dim.
BIAS::Vector< double > * AddParamVecDbl(const std::string &name, const std::string &help, const BIAS::Vector< double > &deflt, char cmdshort=0, int Group=GRP_NOSHOW)
Add a parameter that expects a string on command line like "<value0> <value1> <value2> ...
virtual int GetImageSize(unsigned int &Width, unsigned int &Height) const
Obtain image dimensions.
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
enum EColorModel GetColorModel() const
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...
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:
void SetFocalLengthAndAspect(double f, double AspectRatio)
Set the current camera focal length in pixel and the a spect ratio.
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)
double GetUserTime() const
return user time (=system usage time) in msec JW For Win32: user-time is the sum over all processes o...
class TimeMeasure contains functions for timing real time and cpu time.
void MultiplyIP(const T &scalar)
in place multiplication with scalar
int ReadFromCamParamFile(const std::string &filename, const bool silent=false)
Reads a camera data XML file and constructs the ProjectionParametersBase-pointer, using the Projectio...
static int ToGrey(const ImageBase &source, ImageBase &dest)
wrapper for the templated function ToGrey