ObjectModel.h
Go to the documentation of this file.
00001 
00033 #ifndef __OBJECT_MODEL__
00034 #define __OBJECT_MODEL__
00035 
00036 #include "VisualizationModel.h"
00037 #include "DVision.h"
00038 
00039 #include <string>
00040 #include <vector>
00041 #include <opencv/cv.h>
00042 
00043 typedef DVision::PMVS::PLYFile PLYFile;
00044 typedef DVision::SurfSet SurfSet;
00045 
00046 // This flag is to distinguish between code for Opencv > 2.1.1, that defined
00047 // cv::FlannBasedMatcher, and code for OpenCV 2.1.1, that only defines a 
00048 // cv::Index class
00049 // Iif OPENCV_ADV_MATCHER is 1, the code for > 2.1.1 will be used
00050 //#define OPENCV_ADV_MATCHER 0 //cturtle
00051 #define OPENCV_ADV_MATCHER 1 //diamondback
00052 
00053 class ObjectModel
00054 {
00062   private:
00063     // Avoid copies
00064     ObjectModel (const ObjectModel &);
00065     ObjectModel & operator = (const ObjectModel &);
00066     
00067   public:
00068     
00069     ObjectModel();
00070     
00077     ObjectModel(const std::string &dir, bool load_visualization_model);
00078     
00079     virtual ~ObjectModel();
00080     
00090     void loadDirectory(const std::string &dir, bool load_visualization_model);
00091     
00097     static std::string getName(const std::string &dir);
00098     
00104     static bool checkDirectory(const std::string &dir);
00105     
00125     void detectFaces(const SurfSet &scene, std::vector<int>& face_indices,
00126       std::vector<std::vector<int> >& key_indices,
00127       std::vector<std::vector<int> >& scene_indices,
00128       std::vector<std::vector<float> >& distances,
00129       int min_detected_points = 1, int max_correspondences_per_point = 3,
00130       float max_ratio = 0.6);
00131     
00135     inline const VisualizationModel &getVisualizationModel() const
00136     {
00137       return *m_visualization_model;
00138     }
00139     
00140   public:
00141     
00142     struct Face
00143     {
00144       SurfSet surf;
00145       std::vector<PLYFile::PLYPoint> plypoints;
00146       cv::Mat image;
00147       cv::Mat A; // intrinsic parameters of camera
00148       cv::Mat cRo, cto; // Pose of (o)bject in the (c)amera frame that took the 
00149                         // face image
00150       
00151 #if OPENCV_ADV_MATCHER
00152       // Only valid for OpenCV > 2.1.1
00153       cv::FlannBasedMatcher flann_matcher;
00154 #else
00155       cv::flann::Index *flann_matcher;
00156       
00157       Face(): flann_matcher(NULL){}
00158 #endif
00159     };
00160     
00161     std::string Name;
00162     std::vector<Face> Faces;
00163     std::string Type; // "planar", "3D"
00164   
00165   protected:
00166   
00173     //void updateMap(const char *filename, int face_idx, int N);
00174     
00180     //void loadFlann(const std::string &flan_filename,
00181     //  const std::string &keys_filename);
00182   
00183   protected:
00184     /*
00185     cv::flann::Index *m_flann;
00186     SurfSet *m_features;
00187     std::vector<std::vector<std::vector<int> > > m_map; 
00189     */
00190     
00191     VisualizationModel *m_visualization_model;
00192 };
00193 
00194 #endif
00195 


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:32:01