fitting_surface_im.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2012-, Open Perception, Inc.
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  *   * Neither the name of the copyright holder(s) nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * 
00035  *
00036  */
00037 
00038 #ifndef NURBS_FITTING_SURFACE_IM_H
00039 #define NURBS_FITTING_SURFACE_IM_H
00040 
00041 #include <pcl/surface/on_nurbs/nurbs_tools.h>
00042 #include <pcl/surface/on_nurbs/nurbs_data.h>
00043 #include <pcl/surface/on_nurbs/nurbs_solve.h>
00044 
00045 #include <pcl/point_cloud.h>
00046 #include <pcl/point_types.h>
00047 
00048 namespace pcl
00049 {
00050   namespace on_nurbs
00051   {
00052 
00054     class FittingSurfaceIM
00055     {
00056     public:
00057 
00059       struct Parameter
00060       {
00061         double smoothness;
00062         Parameter () :
00063           smoothness (0.1)
00064         {
00065         }
00066       };
00067 
00068     protected:
00069       pcl::PointCloud<pcl::PointXYZRGB>::Ptr m_cloud;
00070       std::vector<int> m_indices;
00071       Eigen::Matrix3d m_intrinsic;
00072       Eigen::Vector4d m_bb;
00073 
00074       ON_NurbsSurface m_nurbs;
00075       pcl::on_nurbs::vector_vec2i m_cps_px; // control points in pixel space
00076       NurbsSolve m_solver;
00077       bool m_quiet;
00078 
00079       pcl::PointXYZRGB
00080       computeMean () const;
00081 
00082     public:
00083 
00084       EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00085 
00086       inline ON_NurbsSurface&
00087       getSurface ()
00088       {
00089         return m_nurbs;
00090       }
00091 
00092     public:
00093       void
00094       setInputCloud (pcl::PointCloud<pcl::PointXYZRGB>::Ptr _cloud);
00095 
00096       void
00097       setIndices (std::vector<int> &_indices);
00098 
00099       void
00100       setCamera (const Eigen::Matrix3d &i);
00101 
00102       void
00103       setCamera (const Eigen::Matrix3f &i);
00104 
00105       static std::vector<double>
00106       getElementVector (const ON_NurbsSurface &nurbs, int dim);
00107 
00108       void
00109       refine ();
00110 
00112       static Eigen::Vector4d
00113       computeIndexBoundingBox (pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud, const std::vector<int> &indices);
00114       //      void
00115       //      compute (int nurbs_order, double damp = 1.0);
00116 
00117     public:
00118       void
00119       initSurface (int order, const Eigen::Vector4d &bb);
00120 
00121       void
00122       assemble (bool inverse_mapping = false);
00123 
00124       void
00125       solve (double damp = 1.0);
00126 
00127       void
00128       updateSurf (double damp);
00129 
00130       Eigen::Vector2d
00131       findClosestElementMidPoint (const ON_NurbsSurface &nurbs, const Eigen::Vector3d &pt);
00132 
00133       Eigen::Vector2d
00134       inverseMapping (const ON_NurbsSurface &nurbs, const Eigen::Vector3d &pt, const Eigen::Vector2d &hint,
00135                       double &error, Eigen::Vector3d &p, Eigen::Vector3d &tu, Eigen::Vector3d &tv, int maxSteps,
00136                       double accuracy, bool quiet);
00137 
00138       void
00139       addPointConstraint (const Eigen::Vector2i &params, double z, double weight, unsigned &row);
00140 
00141       void
00142       addCageInteriorRegularisation (double weight, unsigned &row);
00143 
00144       void
00145       addCageBoundaryRegularisation (double weight, int side, unsigned &row);
00146 
00147       void
00148       addCageCornerRegularisation (double weight, unsigned &row);
00149 
00150       // index routines
00151       int
00152       grc2gl (int I, int J)
00153       {
00154         return m_nurbs.CVCount (1) * I + J;
00155       } // global row/col index to global lexicographic index
00156       int
00157       lrc2gl (int E, int F, int i, int j)
00158       {
00159         return grc2gl (E + i, F + j);
00160       } // local row/col index to global lexicographic index
00161       int
00162       gl2gr (int A)
00163       {
00164         return (static_cast<int> (A / m_nurbs.CVCount (1)));
00165       } // global lexicographic in global row index
00166       int
00167       gl2gc (int A)
00168       {
00169         return (static_cast<int> (A % m_nurbs.CVCount (1)));
00170       } // global lexicographic in global col index
00171 
00172     };
00173   }
00174 }
00175 
00176 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:24:10