ODetect3D.hh
Go to the documentation of this file.
00001 
00009 #ifndef P_DOBJECT_3D_HH
00010 #define P_DOBJECT_3D_HH
00011 
00012 //#include <opencv/cv.h>
00013 #include <opencv2/opencv.hpp>
00014 #include <SiftGPU.h>
00015 #include <blort/Recognizer3D/KeyClusterPair.hh>
00016 #include <blort/Recognizer3D/Definitions.hh>
00017 #include <blort/Recognizer3D/Geometry.hh>
00018 #include <blort/Recognizer3D/Math.hh>
00019 #include <blort/Recognizer3D/Object3D.hh>
00020 #include <blort/Recognizer3D/PoseCv.hh>
00021 #include <blort/Recognizer3D/Vector3.hh>
00022 
00023 namespace P
00024 {
00025 
00026 class ODetect3D
00027 {
00028 public:
00029   class Point3D
00030   {
00031   public:
00032     float x;
00033     float y;
00034     float z;
00035   };
00036   class Point2D
00037   {
00038   public:
00039     float x;
00040     float y;
00041   };
00042 
00043 private:
00044   IplImage *dbg;
00045 
00046   CvMat *cameraMatrix;
00047   CvMat *distCoeffs;
00048 
00049   SiftMatchGPU *matcher;
00050   int matcherSize;
00051 
00052   Array<KeypointDescriptor*> inlier;   //just a container for drawing inlier...
00053 
00054   void DeletePairs(Array<KeyClusterPair*> &matches);
00055   void MatchKeypoints2(Array<KeypointDescriptor *> &keys, Array<CodebookEntry *> &cb, 
00056                        Array<KeyClusterPair*> &matches);
00057   void MatchKeypoints(Array<KeypointDescriptor *> &keys, Array<CodebookEntry *> &cb, 
00058                       Array<KeyClusterPair* > &matches);
00059   void MatchKeypointsGPU(Array<KeypointDescriptor *> &keys, Array<CodebookEntry *> &cb,
00060                          Array<KeyClusterPair* > &matches);
00061   void FitModelRANSAC(Array<KeyClusterPair*> &matches, PoseCv &pose, unsigned &numInl);
00062   void FitModelRANSAC_GPU(Array<KeyClusterPair*> &matches, PoseCv &pose, unsigned &numInl);
00063   void GetRandIdx(unsigned size, unsigned num, P::Array<unsigned> &idx);
00064   void GetInlier(Array<KeyClusterPair*> &matches, PoseCv &pose, int &inl);
00065   bool GetBestCorner(PoseCv &pose, KeypointDescriptor *k, CodebookEntry *cbe,
00066                      Point3D &pos, double &minDist);
00067   void RefinePoseLS(Array<KeyClusterPair*> &matches, PoseCv &pose, unsigned &inl, double &err);
00068   void ComputeConfidence(Array<KeypointDescriptor *> &keys, unsigned &numInl, Object3D &object);
00069 
00070 
00071   inline void ProjectPoint2Image(double xc, double yc, double zc,
00072                                  CvMat *C, double &xi, double &yi);
00073   inline void CopyPoseCv(PoseCv &in, PoseCv &out);
00074 
00075   //BENCE
00076   Array<KeyClusterPair*> matches;
00077   double nn_far_enough_threshold;
00078   unsigned int n_points_to_match;
00079 
00080 public:
00081   ODetect3D();
00082   ~ODetect3D();
00083 
00084   bool Detect(Array<KeypointDescriptor *> &keys, Object3D &object);
00085 
00086   void SetCameraParameter(CvMat *C);
00087 
00088   void SetDebugImage(IplImage *img){dbg = img;}
00089 
00090   void DrawInlier(IplImage *img, CvScalar col);
00091 
00092   //BENCE
00093   void setNNThreshold(double nn_threshold)
00094   {
00095       nn_far_enough_threshold = nn_threshold;
00096   }
00097 
00098   void setNPointsToMatch(unsigned int n)
00099   {
00100       n_points_to_match = n;
00101   }
00102 };
00103 
00104 /*********************** INLINE METHODES **************************/
00109 inline void ODetect3D::ProjectPoint2Image(double xc, double yc, double zc,
00110                                           CvMat *C, double &xi, double &yi)
00111 {
00112   xi = C->data.fl[0] * xc/zc + C->data.fl[2];
00113   yi = C->data.fl[4] * yc/zc + C->data.fl[5];
00114 }
00115 
00116 inline void ODetect3D::CopyPoseCv(PoseCv &in, PoseCv &out)
00117 {
00118   cvCopy(in.R, out.R);
00119   cvCopy(in.t, out.t);
00120   cvCopy(in.n, out.n);
00121 }
00122 
00123 
00124 }
00125 
00126 #endif
00127 


blort
Author(s): Michael Zillich, Thomas Mörwald, Johann Prankl, Andreas Richtsfeld, Bence Magyar (ROS version)
autogenerated on Thu Jan 2 2014 11:38:25