ModelObject3D.hh
Go to the documentation of this file.
00001 
00007 #ifndef P_COMPUTE_OBJECT_MODEL_3D_HH
00008 #define P_COMPUTE_OBJECT_MODEL_3D_HH
00009 
00010 #include <blort/Recognizer3D/PNamespace.hh>
00011 #include <blort/Recognizer3D/Object3D.hh>
00012 #include <blort/Recognizer3D/Array.hh>
00013 #include <blort/Recognizer3D/Definitions.hh>
00014 #include <blort/Recognizer3D/CodebookEntry.hh>
00015 #include <blort/Recognizer3D/Geometry.hh>
00016 #include <string>
00017 
00018 namespace P
00019 {
00020 
00025 class ModelObject3D
00026 {
00027 private:
00028   void ComputeNewHnorm(P::Array<KeypointDescriptor*> &keys, double Hnorm[9]);
00029   void InsertMeanShift(Array<KeypointDescriptor* > &keys, P::Array<CodebookEntry*> &codebook, double H[9]);
00030 
00031 
00032 public:
00033   ModelObject3D();
00034   ~ModelObject3D();
00035 
00036   void AddToModel(Array<KeypointDescriptor *> &keys, Object3D &obj);
00037   void SaveModel(const char *filename, Object3D &obj);
00038   bool LoadModel(const std::string filename, Object3D &obj);
00039 
00040   inline void MapPoint(double xin, double yin, double H[9], double &xout, double &yout);
00041   inline void MapPoint(double in[2], double H[9], double out[2]);
00042   inline void GetPosScaleAngle( double x, double y, double H[9], double &xr, double &yr, double &scale, double &angle);
00043 
00044 };
00045 
00046 
00047 /*********************** INLINE METHODES **************************/
00048 
00053 inline void ModelObject3D::MapPoint(double xin, double yin, double H[9], double &xout, double &yout)
00054 {
00055   xout = H[0]*xin + H[1]*yin + H[2];
00056   yout = H[3]*xin + H[4]*yin + H[5];
00057   double t = H[6]*xin + H[7]*yin + H[8];
00058   xout /= t;
00059   yout /= t;
00060 }
00061 
00066 inline void ModelObject3D::MapPoint(double in[2], double H[9], double out[2])
00067 {
00068   out[0] = H[0]*in[0] + H[1]*in[1] + H[2];
00069   out[1] = H[3]*in[0] + H[4]*in[1] + H[5];
00070   double t = H[6]*in[0] + H[7]*in[1] + H[8];
00071   out[0] /= t;
00072   out[1] /= t;
00073 }
00074 
00078 inline void ModelObject3D::GetPosScaleAngle( double x, double y, double H[9], double &xr, double &yr, double &scale, double &angle)
00079 {
00080   double x2=x+10.;
00081   double y2=y;
00082   double x2H,y2H;
00083   MapPoint(x,y,H,xr,yr);
00084   MapPoint(x2,y2,H,x2H,y2H);
00085 
00086   double dxH=x2H-xr;
00087   double dyH=y2H-yr;
00088   scale=((sqrt(dxH*dxH+dyH*dyH))/10.);
00089   angle=atan2(dyH,dxH);
00090 }
00091 
00092 
00093 }
00094 
00095 #endif
00096 


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