Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 #ifndef SCENE_RECOG_H
00034 #define SCENE_RECOG_H
00035 
00036 #include <vector>
00037 #include <algorithm>
00038 #include <math.h>
00039 #include <string>
00040 #include "camera_laser_calibration/scene_recog/point_index.h"
00041 #include "camera_laser_calibration/basic_data/point3d.h"
00042 
00043 #define MAX_PLANE_NUM 8         // The maximum number of planes
00044 #define MAX_DIST 8              // maximum distance of laser scan unit £ºm
00045 #define DIMEN 6                 //  points of small plane
00046 #define THRESH     0.5          // The lower limit threshold value of field point set's covariance matrices eigenvalue . range:(0.0£¬0.01]. unit :m
00047 #define MAXDISTH1  0.3          // The lower limit threshold value of the distance between points which are in field point set and the barycenter .range(0.0£¬1.0] unit £ºm
00048 const float PI = 3.14159f;
00049 struct Plane;
00050 struct CPointTag;
00051 
00052 enum FeatureType                
00053 {
00054   NoFeature,
00055   Wall,
00056   Ceiling,
00057   Floor,
00058   Noise,
00059 };
00060 
00061 struct Plane
00062 {
00063   FeatureType Type;             
00064   int VecNum;                   
00065   CPoint3d VecSum;              
00066   CPoint3d VecAve;              
00067   CPoint3d MeanVal;             
00068   CPoint3d MeanSum;             
00069   float A, B, C, D;             
00070   std::vector < CPointIndex > InnerPoints;    
00071     Plane ()
00072   {
00073     Type = NoFeature;
00074     VecNum = 0;
00075     VecSum = CPoint3d (0, 0, 0);
00076     VecAve = CPoint3d (0, 0, 0);
00077     MeanSum = CPoint3d (0, 0, 0);
00078     MeanVal = CPoint3d (0, 0, 0);
00079     A = B = C = D = 0.0;
00080   };
00081 };
00082 
00083 
00084 struct CPointTag
00085 {
00086   int pflag;                    
00087   FeatureType Type;             
00088   int g_flag;                   
00089     CPointTag ()
00090   {
00091     pflag = -1;
00092     g_flag = -1;
00093     Type = NoFeature;
00094   }
00095 };
00096 
00097 
00098 class CSceneRecog
00099 {
00100 public:
00101         CSceneRecog (void);
00102   ~CSceneRecog (void);
00103    
00104   int L_width_, L_height_;      
00105   std::vector < std::vector < CPoint3d > >laser_data_;        
00106   std::vector < Plane > plane_vector_;        
00107   std::vector < std::vector < CPointTag > >point_tag_vector_; 
00108   std::vector < std::vector < CPointIndex > >boundary_vec_;   
00109   std::vector < std::vector < CPointIndex > >convex_vec_;     
00110   float plane_parameters_[4];
00111   
00112 
00113   void srProcess (std::vector < std::vector < CPoint3d > >&data);       
00114   void srPlaneExtract ();       
00115   void srStructureExtract ();   
00116 
00117   float srPtopDistan (CPoint3d p1, CPoint3d p2);        
00118   bool srIsAPlane (CPoint3d p[][DIMEN], CPoint3d m);    
00119   int srEigenValue (float a[], int n, double eps, int jt);      
00120   CPoint3d srNormalVec (CPoint3d start1, CPoint3d end1, CPoint3d start2, CPoint3d end2);        
00121   CPoint3d srVecMuti (CPoint3d start1, CPoint3d end1, CPoint3d start2, CPoint3d end2);  
00122   float srAngle (CPoint3d vec1, CPoint3d vec2); 
00123   bool srCompL1R0bool (const CPointIndex & p1, const CPointIndex & p2, const CPointIndex & p3);
00124   inline int srCross_Product (const CPointIndex & p1, const CPointIndex & p2, const CPointIndex & p3);
00125   float srP2Pl (CPoint3d m, const Plane & Plane);
00126   void srCalColor (int idx, std::vector < float >&rgb);
00127 };
00128 
00129 #endif