range_image_visualizer.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, Willow Garage, Inc.
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 Willow Garage, Inc. 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 #include <pcl/pcl_config.h>
00036 
00037 #include <pcl/visualization/range_image_visualizer.h>
00038 
00039 pcl::visualization::RangeImageVisualizer::RangeImageVisualizer (const std::string& name) : ImageViewer (name), name_ ()
00040 {
00041 }
00042 
00043 pcl::visualization::RangeImageVisualizer::~RangeImageVisualizer ()
00044 {
00045 }
00046 
00047 // void 
00048 // pcl::visualization::RangeImageVisualizer::setRangeImage (const pcl::RangeImage& range_image, float min_value, float max_value, bool grayscale)
00049 // {
00050 //   float* ranges = range_image.getRangesArray ();
00051 //   setFloatImage(ranges, range_image.width, range_image.height, min_value, max_value, grayscale);
00052   
00053 //   delete[] ranges;
00054 // }
00055 
00056 void 
00057 pcl::visualization::RangeImageVisualizer::showRangeImage (const pcl::RangeImage& range_image, float min_value, float max_value, bool grayscale)
00058 {
00059   float* ranges = range_image.getRangesArray ();
00060   showFloatImage(ranges, range_image.width, range_image.height, min_value, max_value, grayscale);
00061   
00062   delete[] ranges;
00063 }
00064 
00065 pcl::visualization::RangeImageVisualizer* 
00066 pcl::visualization::RangeImageVisualizer::getRangeImageWidget (
00067     const pcl::RangeImage& range_image, float min_value, float max_value, bool grayscale, const std::string& name)
00068 {
00069   RangeImageVisualizer* range_image_widget = new RangeImageVisualizer (name);
00070   range_image_widget->showRangeImage (range_image, min_value, max_value, grayscale);
00071   return range_image_widget;
00072 }
00073 
00074 void 
00075 pcl::visualization::RangeImageVisualizer::visualizeBorders (
00076     const pcl::RangeImage& range_image, float min_value, float max_value, bool grayscale,
00077     const pcl::PointCloud<pcl::BorderDescription>& border_descriptions)
00078 {  
00079   showRangeImage(range_image, min_value, max_value, grayscale);
00080   for (size_t y=0; y<range_image.height; ++y)
00081   {
00082     for (size_t x=0; x<range_image.width; ++x)
00083     {
00084       const pcl::BorderDescription& border_description = border_descriptions.points[y*range_image.width + x];
00085       const pcl::BorderTraits& border_traits = border_description.traits;
00086       if (border_traits[pcl::BORDER_TRAIT__OBSTACLE_BORDER])
00087       {
00088         markPoint (x, y, green_color);
00089         //for (unsigned int i = 0; i < border_description.neighbors.size(); ++i)
00090           //range_image_widget->markLine (border_description.x, border_description.y,
00091                                         //border_description.neighbors[i]->x, border_description.neighbors[i]->y, wxGREEN_PEN);
00092       }
00093       else if (border_traits[pcl::BORDER_TRAIT__SHADOW_BORDER])
00094         markPoint(x, y, blue_color);
00095       else if (border_traits[pcl::BORDER_TRAIT__VEIL_POINT])
00096         markPoint(x, y, red_color);
00097     }
00098   }
00099 }
00100 
00101 pcl::visualization::RangeImageVisualizer* 
00102 pcl::visualization::RangeImageVisualizer::getRangeImageBordersWidget (
00103     const pcl::RangeImage& range_image, float min_value, float max_value, bool grayscale,
00104     const pcl::PointCloud<pcl::BorderDescription>& border_descriptions, const std::string& name)
00105 {
00106   //std::cout << PVARN(range_image)<<PVARN(min_value)<<PVARN(max_value)<<PVARN(grayscale);
00107   RangeImageVisualizer* range_image_widget = new RangeImageVisualizer;
00108   range_image_widget->visualizeBorders (range_image, min_value, max_value, grayscale,
00109                                         border_descriptions);
00110   range_image_widget->setWindowTitle (name);
00111   return range_image_widget;
00112 }
00113 
00114 pcl::visualization::RangeImageVisualizer* 
00115 pcl::visualization::RangeImageVisualizer::getAnglesWidget (const pcl::RangeImage& range_image, float* angles_image,
00116                                                            const std::string& name)
00117 {
00118   RangeImageVisualizer* widget = new RangeImageVisualizer;
00119   widget->showAngleImage(angles_image, range_image.width, range_image.height);
00120   widget->setWindowTitle (name);
00121   return widget;
00122 }
00123 
00124 pcl::visualization::RangeImageVisualizer* 
00125 pcl::visualization::RangeImageVisualizer::getHalfAnglesWidget (const pcl::RangeImage& range_image,
00126                                                                 float* angles_image, const std::string& name)
00127 {
00128   RangeImageVisualizer* widget = new RangeImageVisualizer;
00129   widget->showHalfAngleImage(angles_image, range_image.width, range_image.height);
00130   widget->setWindowTitle (name);
00131   return widget;
00132 }
00133 
00134 pcl::visualization::RangeImageVisualizer* 
00135 pcl::visualization::RangeImageVisualizer::getInterestPointsWidget (
00136     const pcl::RangeImage& range_image, const float* interest_image, float min_value, float max_value, 
00137     const pcl::PointCloud<pcl::InterestPoint>& interest_points, const std::string& name)
00138 {
00139   RangeImageVisualizer* widget = new RangeImageVisualizer;
00140   widget->showFloatImage (interest_image, range_image.width, range_image.height, min_value, max_value);
00141   widget->setWindowTitle (name);
00142   for (unsigned int i=0; i<interest_points.points.size(); ++i)
00143   {
00144     const pcl::InterestPoint& interest_point = interest_points.points[i];
00145     float image_x, image_y;
00146     range_image.getImagePoint (interest_point.x, interest_point.y, interest_point.z, image_x, image_y);
00147     widget->markPoint (static_cast<size_t> (image_x), static_cast<size_t> (image_y), green_color, red_color);
00148     //cout << "Marking point "<<image_x<<","<<image_y<<"\n";
00149   }
00150   return widget;
00151 }


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:17:37