manual_registration.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  * 
00004  * Point Cloud Library (PCL) - www.pointclouds.org
00005  * Copyright (c) 2012-, Open Perception, Inc.
00006  * 
00007  * All rights reserved.
00008  * 
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met: 
00012  * 
00013  *  * Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  *  * Redistributions in binary form must reproduce the above
00016  *    copyright notice, this list of conditions and the following
00017  *    disclaimer in the documentation and/or other materials provided
00018  *    with the distribution.
00019  *  * Neither the name of the copyright holder(s) nor the names of its
00020  *    contributors may be used to endorse or promote products derived
00021  *    from this software without specific prior written permission.
00022  * 
00023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  * POSSIBILITY OF SUCH DAMAGE.
00035  */
00036 
00037 #include <ui_manual_registration.h>
00038 
00039 // QT4
00040 #include <QMainWindow>
00041 #include <QMutex>
00042 #include <QTimer>
00043 
00044 // Boost
00045 #include <boost/thread/thread.hpp>
00046 
00047 // PCL
00048 #include <pcl/console/print.h>
00049 #include <pcl/console/parse.h>
00050 
00051 #include <pcl/common/common.h>
00052 #include <pcl/common/angles.h>
00053 #include <pcl/common/time.h>
00054 #include <pcl/common/transforms.h>
00055 
00056 #include <pcl/point_cloud.h>
00057 #include <pcl/point_types.h>
00058 
00059 #include <pcl/io/pcd_grabber.h>
00060 #include <pcl/io/pcd_io.h>
00061 
00062 #include <pcl/visualization/pcl_visualizer.h>
00063 #include <pcl/visualization/point_cloud_handlers.h>
00064 
00065 #include <pcl/registration/transformation_estimation_svd.h>
00066 
00067 typedef pcl::PointXYZRGBA PointT;
00068 
00069 // Useful macros
00070 #define FPS_CALC(_WHAT_) \
00071 do \
00072 { \
00073     static unsigned count = 0;\
00074     static double last = pcl::getTime ();\
00075     double now = pcl::getTime (); \
00076     ++count; \
00077     if (now - last >= 1.0) \
00078     { \
00079       std::cout << "Average framerate("<< _WHAT_ << "): " << double(count)/double(now - last) << " Hz" <<  std::endl; \
00080       count = 0; \
00081       last = now; \
00082     } \
00083 }while(false)
00084 
00085 namespace Ui
00086 {
00087   class MainWindow;
00088 }
00089 
00090 class ManualRegistration : public QMainWindow
00091 {
00092   Q_OBJECT
00093   public:
00094     typedef pcl::PointCloud<PointT> Cloud;
00095     typedef Cloud::Ptr CloudPtr;
00096     typedef Cloud::ConstPtr CloudConstPtr;
00097 
00098     ManualRegistration ();
00099 
00100     ~ManualRegistration ()
00101     {
00102     }
00103 
00104     void
00105     setSrcCloud (pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_src)
00106     {
00107       cloud_src_ = cloud_src;
00108       cloud_src_present_ = true;
00109     }
00110     void
00111     setDstCloud (pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_dst)
00112     {
00113       cloud_dst_ = cloud_dst;
00114       cloud_dst_present_ = true;
00115     }
00116 
00117     void
00118     SourcePointPickCallback (const pcl::visualization::PointPickingEvent& event, void*);
00119     void
00120     DstPointPickCallback (const pcl::visualization::PointPickingEvent& event, void*);
00121 
00122   protected:
00123     boost::shared_ptr<pcl::visualization::PCLVisualizer> vis_src_;
00124     boost::shared_ptr<pcl::visualization::PCLVisualizer> vis_dst_;
00125 
00126     pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_src_;
00127     pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_dst_;
00128 
00129     QMutex mtx_;
00130     QMutex vis_mtx_;
00131     Ui::MainWindow *ui_;
00132     QTimer *vis_timer_;
00133 
00134     bool                              cloud_src_present_;
00135     bool                              cloud_src_modified_;
00136     bool                              cloud_dst_present_;
00137     bool                              cloud_dst_modified_;
00138 
00139     bool                              src_point_selected_;
00140     bool                              dst_point_selected_;
00141 
00142     pcl::PointXYZ                     src_point_;
00143     pcl::PointXYZ                     dst_point_;
00144 
00145     pcl::PointCloud<pcl::PointXYZ>    src_pc_;
00146     pcl::PointCloud<pcl::PointXYZ>    dst_pc_;
00147 
00148     Eigen::Matrix4f                   transform_;
00149 
00150   public slots:
00151     void 
00152     confirmSrcPointPressed();
00153     void 
00154     confirmDstPointPressed();
00155     void 
00156     calculatePressed();
00157     void
00158     clearPressed();
00159     void 
00160     orthoChanged(int state);
00161     void 
00162     applyTransformPressed();
00163     void
00164     refinePressed();
00165     void
00166     undoPressed();
00167     void
00168     safePressed();
00169 
00170   private slots:
00171     void
00172     timeoutSlot();
00173 
00174 };


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