ndt_frame_viewer.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, AASS Research Center, Orebro University.
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 AASS Research Center 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 #ifndef NDTFRAMEVIEWER_HH
00036 #define NDTFRAMEVIEWER_HH
00037 
00038 #include <ndt_feature_reg/ndt_frame.h>
00039 #include <ndt_feature_reg/ndt_frame_proc.h>
00040 #include <pcl/visualization/pcl_visualizer.h>
00041 
00042 #include "opencv2/core/core.hpp"
00043 #include "opencv2/highgui/highgui.hpp"
00044 
00045 namespace ndt_feature_reg
00046 {
00047 inline void viewKeypointMatches(NDTFrameProc *proc, int delay)
00048 {
00049     if (proc->frames.size() < 2)
00050         return;
00051     cv::Mat display;
00052     int i = proc->frames.size()-1;
00053     cv::drawMatches(proc->frames[i-1]->img, proc->frames[i-1]->kpts, proc->frames[i]->img, proc->frames[i]->kpts, proc->pe.inliers, display);
00054     const std::string window_name = "matches";
00055     cv::namedWindow(window_name,0);
00056     cv::imshow(window_name, display);
00057     cv::waitKey(delay);
00058 }
00059 inline void viewKeypointMatchesFirst(NDTFrameProc *proc, int delay)
00060 {
00061     if (proc->frames.size() < 2)
00062         return;
00063     cv::Mat display;
00064     int i = proc->frames.size()-1;
00065     cv::drawMatches(proc->frames[0]->img, proc->frames[0]->kpts, proc->frames[i]->img, proc->frames[i]->kpts, proc->pe.inliers, display);
00066     const std::string window_name = "matches";
00067     cv::namedWindow(window_name,0);
00068     cv::imshow(window_name, display);
00069     cv::waitKey(delay);
00070 }
00071 
00072 class NDTFrameViewer
00073 {
00074 public:
00075     NDTFrameViewer(NDTFrameProc *proc);
00076     void showPC();
00077     void showFeaturePC();
00078     void showNDT();
00079     void showMatches(const std::vector<cv::DMatch> &matches);
00080     void showMatches(const std::vector<std::pair<int,int> > &matches);
00081     boost::shared_ptr<pcl::visualization::PCLVisualizer>& getViewerPtr()
00082     {
00083         return _viewer;
00084     }
00085     bool wasStopped();
00086     void spinOnce();
00087 private:
00088     void initViewer();
00089     boost::shared_ptr<pcl::visualization::PCLVisualizer> _viewer;
00090     NDTFrameProc *_proc;
00091 
00092     inline pcl::PointXYZRGB getPCLColor(int r, int g, int b)
00093     {
00094         pcl::PointXYZRGB ret;
00095         ret.r = r;
00096         ret.g = g;
00097         ret.b = b;
00098         return ret;
00099     }
00100 
00101     inline pcl::PointXYZRGB getPCLColor(size_t i)
00102     {
00103         pcl::PointXYZRGB ret;
00104 
00105         switch (i)
00106         {
00107         case 0:
00108             ret.r = 255;
00109             ret.g = 0;
00110             ret.b = 0;
00111             return ret;
00112         case 1:
00113             ret.r = 0;
00114             ret.g = 255;
00115             ret.b = 0;
00116             return ret;
00117         case 2:
00118             ret.r = 0;
00119             ret.g = 0;
00120             ret.b = 255;
00121             return ret;
00122         default:
00123             ret.r = 0;
00124             ret.g = 0;
00125             ret.b = 0;
00126         }
00127         return ret;
00128     }
00129 
00130 };
00131 }
00132 //#include <ndt_feature_reg/impl/ndt_frame_viewer.hpp>
00133 
00134 #endif


ndt_feature_reg
Author(s): Henrik Andreasson, Todor Stoyanov, Jari Saarinen
autogenerated on Wed Aug 26 2015 15:25:07