bazar  1.3.1
camera.h
Go to the documentation of this file.
1 #ifndef _CAMERA_H
2 #define _CAMERA_H
3 
4 #include "matvec.h"
5 
26 public:
28  PerspectiveProjection(int w, int h, double f, double g, double cx, double, double s=0);
29  void set(int w, int h, double f, double g, double cx , double cy, double s=0);
30 
31  void eyeToImage(const double eye[3], double uv[2]) const;
32  void imageToEye(const double uv[2], double eye[3], double w=0) const;
33  void imageToEye(double u, double v, double eye[3], double w=0) const;
34 
35  void setGlProjection() const;
36 
37  bool setPlanes(double near, double far);
38 
39  bool getUndistortMap(CvMat *xmap, CvMat *ymap);
40 
41 //protected:
42  // intrinsic parameters
43  double f, g, cx, cy, s;
44  double distortion;
46  int width, height;
48 
49  void cmpEyeToImageMat();
50 
51  void flip();
52 };
53 
57 public:
59 
60  void worldToImage(const double p[3], double uvw[3]) const;
61  void worldToImage(const Vec3 &p, Vec3 &uvw) const;
62  void worldToEye(const Vec3 &src, Vec3 &dst) const;
63  void worldToEye(const double src[3], double dst[3]) const;
64  void eyeToWorld(const Vec3 &uvw, Vec3 &w) const;
65  void imageToWorld(double u, double v, Vec3 &w, double z=0) const;
66  void setGlModelView() const;
67  void setByTarget(const Vec3 pos, const Vec3 target, double roll);
68  void loadTdir(const double tdir[3][4], int w, int h);
69  bool loadTdir(const char *tdir, int w, int h);
70  bool loadTdir(const char *tdir); // width and height are estimated. Do not trust it!
71  void clearExternalParams();
72 
74  void translate(double dx, double dy, double dz);
75 
76  void setWorldToEyeMat(const Mat3x4 &m);
77  const Mat3x4 &getWorldToEyeMat() const { return worldToEyeMat; }
78  const Mat3x4 &getEyeToWorldMat() const { return eyeToWorldMat; }
79  const Mat3x4 &getWorldToImageMat() const { return worldToImageMat; }
80 
81  void cmpWorldToImageMat();
82 
84  bool saveTdir(const char *file);
85 
86 protected:
87  // extrinsic parameters
91 };
92 
93 std::ostream& operator << (std::ostream& os, const PerspectiveProjection &cam);
94 std::ostream& operator << (std::ostream& os, const PerspectiveCamera &cam);
95 
96 #endif