00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2009-2012, Willow Garage, Inc. 00006 * Copyright (c) 2012-, Open Perception, Inc. 00007 * 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions 00012 * are met: 00013 * 00014 * * Redistributions of source code must retain the above copyright 00015 * notice, this list of conditions and the following disclaimer. 00016 * * Redistributions in binary form must reproduce the above 00017 * copyright notice, this list of conditions and the following 00018 * disclaimer in the documentation and/or other materials provided 00019 * with the distribution. 00020 * * Neither the name of the copyright holder(s) nor the names of its 00021 * contributors may be used to endorse or promote products derived 00022 * from this software without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00025 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00026 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00027 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00028 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00029 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00030 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00031 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00033 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00034 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00035 * POSSIBILITY OF SUCH DAMAGE. 00036 * 00037 * $Id$ 00038 * 00039 */ 00040 00041 #ifndef PCL_APPS_IN_HAND_SCANNER_OFFLINE_INTEGRATION_H 00042 #define PCL_APPS_IN_HAND_SCANNER_OFFLINE_INTEGRATION_H 00043 00044 #include <vector> 00045 #include <string> 00046 00047 #include <pcl/pcl_exports.h> 00048 #include <pcl/common/time.h> 00049 #include <pcl/apps/in_hand_scanner/common_types.h> 00050 #include <pcl/apps/in_hand_scanner/boost.h> 00051 #include <pcl/apps/in_hand_scanner/eigen.h> 00052 #include <pcl/apps/in_hand_scanner/opengl_viewer.h> 00053 00055 // Forward declarations 00057 00058 namespace pcl 00059 { 00060 template <class PointInT, class PointOutT> 00061 class IntegralImageNormalEstimation; 00062 00063 namespace ihs 00064 { 00065 class Integration; 00066 } // End namespace ihs 00067 } // End namespace pcl 00068 00070 // OfflineIntegration 00072 00073 namespace pcl 00074 { 00075 namespace ihs 00076 { 00080 class PCL_EXPORTS OfflineIntegration : public pcl::ihs::OpenGLViewer 00081 { 00082 Q_OBJECT 00083 00084 public: 00085 00086 typedef pcl::ihs::OpenGLViewer Base; 00087 typedef pcl::ihs::OfflineIntegration Self; 00088 00090 explicit OfflineIntegration (Base* parent=0); 00091 00093 ~OfflineIntegration (); 00094 00095 public slots: 00096 00098 void 00099 start (); 00100 00101 private slots: 00102 00104 void 00105 computationThread (); 00106 00107 private: 00108 00109 typedef pcl::PointXYZRGBA PointXYZRGBA; 00110 typedef pcl::PointCloud <PointXYZRGBA> CloudXYZRGBA; 00111 typedef CloudXYZRGBA::Ptr CloudXYZRGBAPtr; 00112 typedef CloudXYZRGBA::ConstPtr CloudXYZRGBAConstPtr; 00113 00114 typedef pcl::PointXYZRGBNormal PointXYZRGBNormal; 00115 typedef pcl::PointCloud <PointXYZRGBNormal> CloudXYZRGBNormal; 00116 typedef CloudXYZRGBNormal::Ptr CloudXYZRGBNormalPtr; 00117 typedef CloudXYZRGBNormal::ConstPtr CloudXYZRGBNormalConstPtr; 00118 00119 typedef pcl::ihs::Mesh Mesh; 00120 typedef pcl::ihs::MeshPtr MeshPtr; 00121 typedef pcl::ihs::MeshConstPtr MeshConstPtr; 00122 00123 typedef pcl::ihs::Integration Integration; 00124 typedef boost::shared_ptr <Integration> IntegrationPtr; 00125 typedef boost::shared_ptr <const Integration> IntegrationConstPtr; 00126 00127 typedef pcl::IntegralImageNormalEstimation <PointXYZRGBA, PointXYZRGBNormal> NormalEstimation; 00128 typedef boost::shared_ptr <NormalEstimation> NormalEstimationPtr; 00129 typedef boost::shared_ptr <const NormalEstimation> NormalEstimationConstPtr; 00130 00132 class ComputationFPS : public Base::FPS 00133 { 00134 public: 00135 ComputationFPS () : Base::FPS () {} 00136 ~ComputationFPS () {} 00137 }; 00138 00139 00141 class VisualizationFPS : public Base::FPS 00142 { 00143 public: 00144 VisualizationFPS () : Base::FPS () {} 00145 ~VisualizationFPS () {} 00146 }; 00147 00154 bool 00155 getFilesFromDirectory (const std::string path_dir, 00156 const std::string extension, 00157 std::vector <std::string>& files) const; 00158 00164 bool 00165 loadTransform (const std::string& filename, 00166 Eigen::Matrix4f& transform) const; 00167 00174 bool 00175 load (const std::string& filename, 00176 CloudXYZRGBNormalPtr& cloud, 00177 Eigen::Matrix4f& T) const; 00178 00182 void 00183 paintEvent (QPaintEvent* event); 00184 00186 void 00187 keyPressEvent (QKeyEvent* event); 00188 00190 // Members 00192 00194 boost::mutex mutex_; 00195 00197 boost::mutex mutex_quit_; 00198 00200 ComputationFPS computation_fps_; 00201 00203 VisualizationFPS visualization_fps_; 00204 00206 std::string path_dir_; 00207 00209 MeshPtr mesh_model_; 00210 00212 NormalEstimationPtr normal_estimation_; 00213 00215 IntegrationPtr integration_; 00216 00218 bool destructor_called_; 00219 00220 public: 00221 00222 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00223 }; 00224 } // End namespace ihs 00225 } // End namespace pcl 00226 00227 #endif // PCL_APPS_IN_HAND_SCANNER_OFFLINE_INTEGRATION_H