quadric.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2015, Andreas ten Pas
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *
00018  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00021  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00022  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00023  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00024  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00026  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00027  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00028  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029  *  POSSIBILITY OF SUCH DAMAGE.
00030  */
00031 
00032 #ifndef QUADRIC_H
00033 #define QUADRIC_H
00034 
00035 #include <Eigen/Dense>
00036 #include <pcl/point_cloud.h>
00037 #include <pcl/point_types.h>
00038 #include <pcl/visualization/pcl_visualizer.h>
00039 #include <vector>
00040 
00042 extern "C" void dggev_(const char* JOBVL, const char* JOBVR, const int* N, const double* A, const int* LDA,
00043                        const double* B, const int* LDB, double* ALPHAR, double* ALPHAI, double* BETA, double* VL,
00044                        const int* LDVL, double* VR, const int* LDVR, double* WORK, const int* LWORK, int* INFO);
00045 
00055 class Quadric
00056 {
00057 public:
00058 
00062   Quadric()
00063   {
00064   }
00065 
00073   Quadric(const std::vector<Eigen::Matrix4d, Eigen::aligned_allocator<Eigen::Matrix4d> >& T_cams,
00074           const pcl::PointCloud<pcl::PointXYZ>::Ptr& input, const Eigen::Vector3d& sample, bool is_deterministic);
00075   
00081   void findTaubinNormalAxis(const std::vector<int> &indices, const Eigen::VectorXi& cam_source);
00082         
00087         void fitQuadric(const std::vector<int>& indices);
00088 
00093         void setInputCloud(const pcl::PointCloud<pcl::PointXYZ>::Ptr& input)
00094         {
00095                 this->input_ = input;
00096         }
00097         
00101         void print();
00102         
00108         void plotAxes(void* viewer_void, int id) const;
00109         
00114         const Eigen::Vector3d& getSample() const
00115         {
00116                 return sample_;
00117         }
00118         
00123         const Eigen::Vector3d& getBinormal() const
00124         {
00125                 return binormal_;
00126         }
00127         
00132         const Eigen::Vector3d& getCurvatureAxis() const
00133         {
00134                 return curvature_axis_;
00135         }
00136         
00141         const Eigen::Vector3d& getNormal() const
00142         {
00143                 return normal_;
00144         }
00145 
00146 
00147 private:
00148 
00153         void findAverageNormalAxis(const Eigen::MatrixXd& normals);
00154         
00158         void unpackQuadric();
00159         
00170   bool solveGeneralizedEigenProblem(const Eigen::MatrixXd& A, const Eigen::MatrixXd& B, Eigen::MatrixXd& v,
00171                                     Eigen::MatrixXd& lambda);
00172 
00173   bool is_deterministic_; 
00174   Eigen::Matrix3Xd cam_origins_; 
00175   Eigen::Vector3d sample_; 
00176   int majority_cam_source_; 
00177   pcl::PointCloud<pcl::PointXYZ>::Ptr input_; 
00178   Eigen::Vector3d curvature_axis_, normal_, binormal_; 
00179   Eigen::Matrix<double, 10, 1> parameters_; 
00180   Eigen::Vector3d centroid_; 
00181   Eigen::Matrix3d covariance_matrix_; 
00182   double normals_ratio_; 
00183   
00184   static const int TAUBIN_MATRICES_SIZE = 10; 
00185 };
00186 
00187 #endif // PCL_FEATURES_CURVATURE_ESTIMATION_TAUBIN_H_


agile_grasp
Author(s):
autogenerated on Thu Aug 27 2015 12:01:28