scene_recog.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 *  Software License Agreement (BSD License)
00003 *  Copyright (c) 2013, Intelligent Robotics Lab, DLUT.
00004 *  All rights reserved.
00005 *  Author:Zhao Cilang,Yan Fei,Zhuang Yan
00006 *  Redistribution and use in source and binary forms, with or without
00007 *  modification, are permitted provided that the following conditions
00008 *  are met:
00009 *
00010 *   * Redistributions of source code must retain the above copyright
00011 *     notice, this list of conditions and the following disclaimer.
00012 *   * Redistributions in binary form must reproduce the above
00013 *     copyright notice, this list of conditions and the following
00014 *     disclaimer in the documentation and/or other materials provided
00015 *     with the distribution.
00016 *   * Neither the name of the Intelligent Robotics Lab nor the names of its
00017 *     contributors may be used to endorse or promote products derived
00018 *     from this software without specific prior written permission.
00019 *
00020 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031 *  POSSIBILITY OF SUCH DAMAGE.
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                //FeatureTypes
00053 {
00054   NoFeature,
00055   Wall,
00056   Ceiling,
00057   Floor,
00058   Noise,
00059 };
00060 // The struct of plane
00061 struct Plane
00062 {
00063   FeatureType Type;             //plane type
00064   int VecNum;                   //The number of small plane- templates
00065   CPoint3d VecSum;              // Sum of normals
00066   CPoint3d VecAve;              // Plane normals
00067   CPoint3d MeanVal;             // Plane barycenter
00068   CPoint3d MeanSum;             // sum of plane barycenter
00069   float A, B, C, D;             //  parameters of plane
00070   std::vector < CPointIndex > InnerPoints;    //The index of 3D points in a plane
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 //The point tag 
00084 struct CPointTag
00085 {
00086   int pflag;                    //The tag which is used to discriminate between the planes.
00087   FeatureType Type;             //The tag to discriminate between frame cloud points.
00088   int g_flag;                   //The tag to discriminate between different objects.
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_;      //The width and height of a laser point cloud
00105   std::vector < std::vector < CPoint3d > >laser_data_;        // Raw 3D points
00106   std::vector < Plane > plane_vector_;        // Vector to save planes.
00107   std::vector < std::vector < CPointTag > >point_tag_vector_; // One-to-one tag with each points 
00108   std::vector < std::vector < CPointIndex > >boundary_vec_;   // The rough bounder of each planes.
00109   std::vector < std::vector < CPointIndex > >convex_vec_;     // Find points in plane convex hull
00110   float plane_parameters_[4];
00111   
00112 // **************************************************************************************
00113   void srProcess (std::vector < std::vector < CPoint3d > >&data);       // Put in the laser data.               
00114   void srPlaneExtract ();       // Tentative fitting
00115   void srStructureExtract ();   // consolidate small planes
00116 // ****************************************************************************************************************
00117   float srPtopDistan (CPoint3d p1, CPoint3d p2);        // distance between points.
00118   bool srIsAPlane (CPoint3d p[][DIMEN], CPoint3d m);    //
00119   int srEigenValue (float a[], int n, double eps, int jt);      //Calculate the eigenvalue of a matrix
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


camera_laser_calibration
Author(s): Zhao Cilang,Yan Fei,Zhuang Yan/zhuang@dlut.edu.cn
autogenerated on Sun Jan 5 2014 11:05:02