test_voronoi.cpp
Go to the documentation of this file.
00001 
00039 #include <iostream>
00040 #include <string>
00041 
00042 #include <opencv2/core/core.hpp>
00043 #include <opencv2/highgui/highgui.hpp>
00044 
00045 #include <bwi_mapper/voronoi_approximator.h>
00046 
00047 int main(int argc, char** argv) {
00048 
00049   if (argc != 2) {
00050     std::cerr << "USAGE: " << argv[0] << " <yaml-map-file>" << std::endl;
00051     return -1;
00052   }
00053 
00054   cv::Mat display_image, image;
00055   nav_msgs::OccupancyGrid map;
00056   std::cout << "Computing Voronoi Points using new approach" << std::endl;
00057   bwi_mapper::VoronoiApproximator voronoi(argv[1]);
00058   voronoi.findVoronoiPoints(0.3);
00059   voronoi.getMap(map);
00060   voronoi.drawMap(display_image, map, 0, 0);
00061   voronoi.drawVoronoiPoints(display_image, 0, 0);
00062   voronoi.drawMap(image);
00063   voronoi.drawVoronoiPoints(image);
00064   cv::imwrite("voronoi_new.png", image);
00065 
00066   std::cout << "Computing Voronoi Points using naive approach and no sub pixel sampling" << std::endl;
00067   bwi_mapper::VoronoiApproximator voronoi2(argv[1]);
00068   voronoi2.findVoronoiPoints(0.3, true, 1);
00069   voronoi2.drawMap(display_image, map, map.info.width, 0);
00070   voronoi2.drawVoronoiPoints(display_image, map.info.width, 0);
00071   voronoi2.drawMap(image);
00072   voronoi2.drawVoronoiPoints(image);
00073   cv::imwrite("voronoi_naive_1.png", image);
00074 
00075   std::cout << "Computing Voronoi Points using naive approach and sub pixel sampling of 2" << std::endl;
00076   bwi_mapper::VoronoiApproximator voronoi3(argv[1]);
00077   voronoi3.findVoronoiPoints(0.3, true, 2);
00078   voronoi3.drawMap(display_image, map, 2*map.info.width, 0);
00079   voronoi3.drawVoronoiPoints(display_image, 2*map.info.width, 0);
00080   voronoi3.drawMap(image);
00081   voronoi3.drawVoronoiPoints(image);
00082   cv::imwrite("voronoi_naive_2.png", image);
00083 
00084   std::cout << "Computing Voronoi Points using naive approach and sub pixel sampling of 4" << std::endl;
00085   bwi_mapper::VoronoiApproximator voronoi4(argv[1]);
00086   voronoi4.findVoronoiPoints(0.3, true, 4);
00087   voronoi4.drawMap(display_image, map, 3*map.info.width, 0);
00088   voronoi4.drawVoronoiPoints(display_image, 3*map.info.width, 0);
00089   voronoi4.drawMap(image);
00090   voronoi4.drawVoronoiPoints(image);
00091   cv::imwrite("voronoi_naive_4.png", image);
00092 
00093   cv::namedWindow("Display window", CV_WINDOW_AUTOSIZE);
00094   cv::imshow("Display window", display_image);                
00095 
00096   cv::waitKey(0); // Wait for a keystroke in the window
00097   return 0;
00098 }
00099 
00100 


bwi_mapper
Author(s): Piyush Khandelwal
autogenerated on Fri Aug 28 2015 10:14:35