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 #pragma once
00034 
00035 #include <vector>
00036 #include <algorithm>
00037 #include <math.h>
00038 #include <string>
00039 #include "PointIndex.h"
00040 #include "../basicData/Point3d.h"
00041 
00042 #define MAX_PLANE_NUM 8         // The maximum number of planes
00043 #define MAX_DIST 8              // maximum distance of laser scan unit £ºm
00044 #define DIMEN 6                 //  points of small plane
00045 #define THRESH     0.5          // The lower limit threshold value of field point set's covariance matrices eigenvalue . range:(0.0£¬0.01]. unit :m
00046 #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
00047 const float PI = 3.14159f;
00048 struct Plane;
00049 struct CPointTag;
00050 
00051 enum FeatureType                
00052 {
00053   NoFeature,
00054   Wall,
00055   Ceiling,
00056   Floor,
00057   Noise,
00058 };
00059 
00060 struct Plane
00061 {
00062   FeatureType Type;             
00063   int VecNum;                   
00064   CPoint3d VecSum;              
00065   CPoint3d VecAve;              
00066   CPoint3d MeanVal;             
00067   CPoint3d MeanSum;             
00068   float A, B, C, D;             
00069   std::vector < CPointIndex > InnerPoints;    
00070     Plane ()
00071   {
00072     Type = NoFeature;
00073     VecNum = 0;
00074     VecSum = CPoint3d (0, 0, 0);
00075     VecAve = CPoint3d (0, 0, 0);
00076     MeanSum = CPoint3d (0, 0, 0);
00077     MeanVal = CPoint3d (0, 0, 0);
00078     A = B = C = D = 0.0;
00079   };
00080 };
00081 
00082 
00083 struct CPointTag
00084 {
00085   int pflag;                    
00086   FeatureType Type;             
00087   int g_flag;                   
00088     CPointTag ()
00089   {
00090     pflag = -1;
00091     g_flag = -1;
00092     Type = NoFeature;
00093   }
00094 };
00095 
00096 
00097 class CSceneRecog
00098 {
00099 public:
00100   int L_width_, L_height_;      
00101   std::vector < std::vector < CPoint3d > >laser_data_;        
00102   std::vector < Plane > plane_vector_;        
00103   std::vector < std::vector < CPointTag > >point_tag_vector_; 
00104   std::vector < std::vector < CPointIndex > >boundary_vec_;   
00105   std::vector < std::vector < CPointIndex > >convex_vec_;     
00106   float plane_parameters_[4];
00107 public:
00108   CSceneRecog (void);
00109    ~CSceneRecog (void);
00110 
00111 
00112   void srProcess (std::vector < std::vector < CPoint3d > >&data);       
00113   void srPlaneExtract ();       
00114   void srStructureExtract ();   
00115 
00116   float srPtopDistan (CPoint3d p1, CPoint3d p2);        
00117   bool srIsAPlane (CPoint3d p[][DIMEN], CPoint3d m);    
00118   int srEigenValue (float a[], int n, double eps, int jt);      
00119   CPoint3d srNormalVec (CPoint3d start1, CPoint3d end1, CPoint3d start2, CPoint3d end2);        
00120   CPoint3d srVecMuti (CPoint3d start1, CPoint3d end1, CPoint3d start2, CPoint3d end2);  
00121   float srAngle (CPoint3d vec1, CPoint3d vec2); 
00122   bool srCompL1R0bool (const CPointIndex & p1, const CPointIndex & p2, const CPointIndex & p3);
00123   inline int srCross_Product (const CPointIndex & p1, const CPointIndex & p2, const CPointIndex & p3);
00124   float srP2Pl (CPoint3d m, const Plane & Plane);
00125   void srCalColor (int idx, std::vector < float >&rgb);
00126 };