SceneRecog.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:Intelligent Robotics Lab, DLUT.
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 #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                //FeatureTypes
00052 {
00053   NoFeature,
00054   Wall,
00055   Ceiling,
00056   Floor,
00057   Noise,
00058 };
00059 // The struct of plane
00060 struct Plane
00061 {
00062   FeatureType Type;             //plane type
00063   int VecNum;                   //The number of small plane- templates
00064   CPoint3d VecSum;              // Sum of normals
00065   CPoint3d VecAve;              // Plane normals
00066   CPoint3d MeanVal;             // Plane barycenter
00067   CPoint3d MeanSum;             // sum of plane barycenter
00068   float A, B, C, D;             //  parameters of plane
00069   std::vector < CPointIndex > InnerPoints;    //The index of 3D points in a plane
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 //The point tag 
00083 struct CPointTag
00084 {
00085   int pflag;                    //The tag which is used to discriminate between the planes.
00086   FeatureType Type;             //The tag to discriminate between frame cloud points.
00087   int g_flag;                   //The tag to discriminate between different objects.
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_;      //The width and height of a laser point cloud
00101   std::vector < std::vector < CPoint3d > >laser_data_;        // Raw 3D points
00102   std::vector < Plane > plane_vector_;        // Vector to save planes.
00103   std::vector < std::vector < CPointTag > >point_tag_vector_; // One-to-one tag with each points 
00104   std::vector < std::vector < CPointIndex > >boundary_vec_;   // The rough bounder of each planes.
00105   std::vector < std::vector < CPointIndex > >convex_vec_;     // Find points in plane convex hull
00106   float plane_parameters_[4];
00107 public:
00108   CSceneRecog (void);
00109    ~CSceneRecog (void);
00110 
00111 // **************************************************************************************
00112   void srProcess (std::vector < std::vector < CPoint3d > >&data);       // Put in the laser data.               
00113   void srPlaneExtract ();       // Tentative fitting
00114   void srStructureExtract ();   // consolidate small planes
00115 // ****************************************************************************************************************
00116   float srPtopDistan (CPoint3d p1, CPoint3d p2);        // distance between points.
00117   bool srIsAPlane (CPoint3d p[][DIMEN], CPoint3d m);    //
00118   int srEigenValue (float a[], int n, double eps, int jt);      //Calculate the eigenvalue of a matrix
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 };


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