Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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
00133
00134 #endif