144 float viewportZMax=1.):
145 chipSize(chipSize), clipZNear(clipZNear), clipZFar(clipZFar), viewport(viewport),
146 viewportZMin(viewportZMin), viewportZMax(viewportZMax) {}
162 const Vec &up=
Vec(1,0,0,1),
165 float sampling_res_x = 200,
166 float sampling_res_y = 200,
169 m_px(principalPointOffset.x), m_py(principalPointOffset.y),
170 m_mx(sampling_res_x), m_my(sampling_res_y), m_skew(skew), m_renderParams(renderParams) {}
177 Camera(
const std::string &filename,
const std::string &prefix=
"config.") ;
183 Camera(std::istream &configDataStream,
const std::string &prefix=
"config.") ;
198 static Camera calibrate(std::vector<Vec> Xws, std::vector<utils::Point32f> xis,
float focalLength=1,
199 bool performLMAOptimization=
true)
205 static Camera calibrate_pinv(std::vector<Vec> Xws, std::vector<utils::Point32f> xis,
float focalLength=1,
206 bool performLMAOptimization=
true)
211 static Camera calibrate_extrinsic(
const std::vector<Vec> &Xws,
const std::vector<utils::Point32f> &xis,
212 const Camera &intrinsicCamValue,
const RenderParams &renderParams=RenderParams(),
213 bool performLMAOptimization=
true)
218 static Camera calibrate_extrinsic(
const std::vector<Vec> &Xws,
const std::vector<utils::Point32f> &xis,
219 const Mat &camIntrinsicProjectionMatrix,
const RenderParams &renderParams=RenderParams(),
220 bool performLMAOptimization=
true)
321 static Camera calibrate_extrinsic(std::vector<Vec> Xws, std::vector<utils::Point32f> xis,
322 float fx,
float fy,
float s,
float px ,
float py,
323 const RenderParams &renderParams=RenderParams(),
324 bool performLMAOptimization=
true)
328 static Camera optimize_camera_calibration_lma(
const std::vector<Vec> &Xws,
329 const std::vector<utils::Point32f> xis,
338 void project(
const std::vector<Vec> &Xws, std::vector<utils::Point32f> &dst)
const;
340 const std::vector<utils::Point32f>
project(
const std::vector<Vec> &Xws)
const;
346 Vec projectGL(
const Vec &Xw)
const;
348 void projectGL(
const std::vector<Vec> &Xws, std::vector<Vec> &dst)
const;
350 const std::vector<Vec> projectGL(
const std::vector<Vec> &Xws)
const;
360 std::vector<ViewRay> getViewRays(
const std::vector<utils::Point32f> &pixels)
const;
389 void setRotation(
const Mat3x3 &rot);
391 void setRotation(
const Vec &rot);
398 void setTransformation(
const Mat &m);
403 void setWorldTransformation(
const Mat &m);
409 void setWorldFrame(
const Mat &m);
412 Mat getCSTransformationMatrix()
const;
415 Mat getInvCSTransformationMatrix()
const;
418 Mat getCSTransformationMatrixGL()
const;
420 Mat getProjectionMatrix()
const;
422 Mat getProjectionMatrixGL()
const;
423 Mat getViewportMatrixGL()
const;
434 std::string toString()
const;
438 const std::string &
getName()
const {
return m_name; }
455 void setName(
const std::string &name) { m_name = name; }
458 m_norm =
norm; m_norm[3] = 0; m_norm.
normalize(); m_norm[3] = 1;
459 if(autoOrthogonalizeRotationMatrix) orthogonalizeRotationMatrix();
462 void setUp(
const Vec &up,
bool autoOrthogonalizeRotationMatrix=
false) {
463 m_up = up; m_up[3] = 0; m_up.
normalize(); m_up[3] = 1;
464 if(autoOrthogonalizeRotationMatrix) orthogonalizeRotationMatrix();
467 void orthogonalizeRotationMatrix();
486 void setResolution(
const utils::Size &newScreenSize);
577 static Vec estimate_3D(
const std::vector<Camera*> cams,
578 const std::vector<utils::Point32f> &UVs,
579 bool removeInvalidPoints=
false) ;
582 Mat estimatePose(
const std::vector<Vec> &objectCoords,
583 const std::vector<utils::Point32f> &imageCoords,
584 bool performLMAOptimization=
true);
589 static Vec estimate_3D_svd(
const std::vector<Camera*> cams,
590 const std::vector<utils::Point32f> &UVs);
600 static Camera create_camera_from_calibration_or_udist_file(
const std::string &filename) ;
603 static Mat createTransformationMatrix(
const Vec &
norm,
const Vec &up,
const Vec &pos);
627 static void checkAndFixPoints(std::vector<Vec> &worldPoints, std::vector<utils::Point32f> &imagePoints)
630 static void load_camera_from_stream(std::istream &is,
631 const std::string &prefix,
Utility structure for calculation of view-ray / plane intersections.
Definition: PlaneEquation.h:41
const utils::Size & getResolution() const
returns the current chipSize (camera resolution in pixels)
Definition: Camera.h:495
undocument this line if you encounter any issues!
Definition: Any.h:37
void setName(const std::string &name)
Definition: Camera.h:455
const Vec & getPosition() const
Definition: Camera.h:439
Vec m_pos
center position vector
Definition: Camera.h:610
ICLQt_API core::Img< T > norm(const core::Img< T > &image)
normalize an images range to [0,255]
math::FixedColVector< T, 4 > cross(const math::FixedMatrix< T, 1, 4 > &v1, const math::FixedMatrix< T, 1, 4 > &v2)
homogeneous 3D cross-product
Definition: HomogeneousMath.h:203
float getPrincipalPointOffsetX() const
Definition: Camera.h:445
void normalize(int iChannel, const utils::Range< Type > &srcRange, const utils::Range< Type > &dstRange)
Scales pixel values from given min/max values to new min/max values (for internal use)
float m_f
focal length
Definition: Camera.h:615
float y
y position of this point
Definition: Point32f.h:48
float getPrincipalPointOffsetY() const
Definition: Camera.h:446
utils::Point32f getPrincipalPointOffset() const
Definition: Camera.h:444
void setPrincipalPointOffset(float px, float py)
Definition: Camera.h:470
#define ICLGeom_API
Definition: CompatMacros.h:179
const std::string & getName() const
Definition: Camera.h:438
std::string m_name
name of the camera (visualized in the scene if set)
Definition: Camera.h:607
const Vec & getUp() const
Definition: Camera.h:441
void setUp(const Vec &up, bool autoOrthogonalizeRotationMatrix=false)
gets automatically normalized
Definition: Camera.h:462
Vec getHoriz() const
Definition: Camera.h:442
float getSamplingResolutionX() const
Definition: Camera.h:447
Vec m_up
vector pointing to pos. y axis on image plane
Definition: Camera.h:612
void setPosition(const Vec &pos)
Definition: Camera.h:456
static const Size VGA
Video Graphics Array res. 640x480.
Definition: Size.h:82
void setSamplingResolutionX(float value)
Definition: Camera.h:472
float m_my
sampling resolution
Definition: Camera.h:617
Camera class.
Definition: Camera.h:132
void setSamplingResolutionY(float value)
Definition: Camera.h:473
void setNorm(const Vec &norm, bool autoOrthogonalizeRotationMatrix=false)
Definition: Camera.h:457
utils::Size chipSize
chip size in [pixels] for transformation to chip coordinates
Definition: Camera.h:136
NotEnoughDataPointsException()
Definition: Camera.h:151
float clipZFar
position of the far clipping plane in [mm]
Definition: Camera.h:138
const RenderParams & getRenderParams() const
Definition: Camera.h:450
ICLGeom_API std::ostream & operator<<(std::ostream &os, const Camera &cam)
ostream operator (writes camera in XML core::format)
void normalize(T norm=2)
inplace normalization
Definition: FixedMatrix.h:844
Size class of the ICL.
Definition: Size.h:61
float m_py
principal point offset
Definition: Camera.h:616
RenderParams m_renderParams
Definition: Camera.h:621
void setPrincipalPointOffset(const utils::Point32f &p)
Definition: Camera.h:471
float getFocalLength() const
Definition: Camera.h:443
ICLGeom_API std::istream & operator>>(std::istream &is, Camera &cam)
istream operator parses a camera from an XML-string
Vec4D32f Vec
Short typedef for 4D float vectors.
Definition: GeomDefs.h:87
We need at least 6 Data points in general positions.
Definition: Camera.h:150
float viewportZMin
Definition: Camera.h:140
const Vec & getNorm() const
Definition: Camera.h:440
void translate(const Vec &d)
translates the current position vector
Definition: Camera.h:432
void setFocalLength(float value)
Definition: Camera.h:469
void setSamplingResolution(float x, float y)
Definition: Camera.h:474
This is a view-ray's line equation in parameter form.
Definition: ViewRay.h:49
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
float getSkew() const
Definition: Camera.h:449
Simple 2D-Array class that provides shallow copy per default.
Definition: Array2D.h:61
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
float m_skew
skew parameter in the camera projection, should be zero
Definition: Camera.h:618
float x
x position of this point
Definition: Point32f.h:45
Base class for Exception handling in the ICL.
Definition: Exception.h:42
math::FixedColVector< T, 4 > project(math::FixedMatrix< T, 1, 4 > v, T z)
perform perspective projection
Definition: HomogeneousMath.h:192
float clipZNear
position of the near clipping plane in [mm]
Definition: Camera.h:137
Rectangle class of the ICL used e.g. for the Images ROI-rect.
Definition: Rect.h:95
utils::Rect viewport
in [pixel]
Definition: Camera.h:139
math::FixedMatrix< icl32f, 3, 3 > Mat3x3
internal typedef
Definition: Camera.h:155
void setSkew(float value)
Definition: Camera.h:475
void setRenderParams(const RenderParams &rp)
Definition: Camera.h:476
Vec m_norm
normal vector of image plane
Definition: Camera.h:611
RenderParams(const utils::Size &chipSize=utils::Size::VGA, float clipZNear=1.0, float clipZFar=10000., const utils::Rect &viewport=utils::Rect(0, 0, 640, 480), float viewportZMin=0., float viewportZMax=1.)
Definition: Camera.h:142
RenderParams & getRenderParams()
Definition: Camera.h:451
float getSamplingResolutionY() const
Definition: Camera.h:448