$search
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 00039 #include <pcl_visualization/range_image_visualizer.h> 00040 00041 pcl_visualization::RangeImageVisualizer::RangeImageVisualizer (const std::string& name) : ImageWidgetWX (), name_ (name) 00042 { 00043 } 00044 00045 pcl_visualization::RangeImageVisualizer::~RangeImageVisualizer () 00046 { 00047 } 00048 00049 void 00050 pcl_visualization::RangeImageVisualizer::setRangeImage (const pcl::RangeImage& range_image, float min_value, float max_value, bool grayscale) 00051 { 00052 //MEASURE_FUNCTION_TIME; 00053 00054 float* ranges = range_image.getRangesArray (); 00055 00056 // Call BaseClass function: 00057 setFloatImage (ranges, range_image.width, range_image.height, name_.c_str (), min_value, max_value, grayscale); 00058 delete[] ranges; 00059 } 00060 00061 pcl_visualization::RangeImageVisualizer* 00062 pcl_visualization::RangeImageVisualizer::getRangeImageWidget ( 00063 const pcl::RangeImage& range_image, float min_value, float max_value, bool grayscale, const std::string& name) 00064 { 00065 RangeImageVisualizer* range_image_widget = new RangeImageVisualizer (name); 00066 range_image_widget->setRangeImage (range_image, min_value, max_value, grayscale); 00067 return range_image_widget; 00068 } 00069 00070 void pcl_visualization::RangeImageVisualizer::visualizeBorders ( 00071 const pcl::RangeImage& range_image, float min_value, float max_value, bool grayscale, 00072 const pcl::PointCloud<pcl::BorderDescription>& border_descriptions) 00073 { 00074 setRangeImage(range_image, min_value, max_value, grayscale); 00075 00076 for (int y=0; y<(int)range_image.height; ++y) 00077 { 00078 for (int x=0; x<(int)range_image.width; ++x) 00079 { 00080 const pcl::BorderDescription& border_description = border_descriptions.points[y*range_image.width + x]; 00081 const pcl::BorderTraits& border_traits = border_description.traits; 00082 if (border_traits[pcl::BORDER_TRAIT__OBSTACLE_BORDER]) 00083 { 00084 markPoint (x, y, wxGREEN_PEN); 00085 //for (unsigned int i = 0; i < border_description.neighbors.size(); ++i) 00086 //range_image_widget->markLine (border_description.x, border_description.y, 00087 //border_description.neighbors[i]->x, border_description.neighbors[i]->y, wxGREEN_PEN); 00088 } 00089 else if (border_traits[pcl::BORDER_TRAIT__SHADOW_BORDER]) 00090 markPoint(x, y, wxCYAN_PEN); 00091 else if (border_traits[pcl::BORDER_TRAIT__VEIL_POINT]) 00092 markPoint(x, y, wxRED_PEN); 00093 } 00094 } 00095 } 00096 00097 pcl_visualization::RangeImageVisualizer* 00098 pcl_visualization::RangeImageVisualizer::getRangeImageBordersWidget ( 00099 const pcl::RangeImage& range_image, float min_value, float max_value, bool grayscale, 00100 const pcl::PointCloud<pcl::BorderDescription>& border_descriptions, const std::string& name) 00101 { 00102 //std::cout << PVARN(range_image)<<PVARN(min_value)<<PVARN(max_value)<<PVARN(grayscale); 00103 RangeImageVisualizer* range_image_widget = new RangeImageVisualizer; 00104 range_image_widget->visualizeBorders (range_image, min_value, max_value, grayscale, 00105 border_descriptions); 00106 range_image_widget->setName (name); 00107 return range_image_widget; 00108 } 00109 00110 pcl_visualization::RangeImageVisualizer* 00111 pcl_visualization::RangeImageVisualizer::getAnglesWidget (const pcl::RangeImage& range_image, float* angles_image, 00112 const std::string& name) 00113 { 00114 RangeImageVisualizer* widget = new RangeImageVisualizer; 00115 widget->setAngleImage(angles_image, range_image.width, range_image.height, name.c_str()); 00116 return widget; 00117 } 00118 00119 pcl_visualization::RangeImageVisualizer* 00120 pcl_visualization::RangeImageVisualizer::getHalfAnglesWidget (const pcl::RangeImage& range_image, 00121 float* angles_image, const std::string& name) 00122 { 00123 RangeImageVisualizer* widget = new RangeImageVisualizer; 00124 widget->setHalfAngleImage(angles_image, range_image.width, range_image.height, name.c_str()); 00125 return widget; 00126 } 00127 00128 pcl_visualization::RangeImageVisualizer* 00129 pcl_visualization::RangeImageVisualizer::getInterestPointsWidget ( 00130 const pcl::RangeImage& range_image, float* interest_image, float min_value, float max_value, 00131 const pcl::PointCloud<pcl::InterestPoint>& interest_points, const std::string& name) 00132 { 00133 RangeImageVisualizer* widget = new RangeImageVisualizer; 00134 widget->setFloatImage (interest_image, range_image.width, range_image.height, name.c_str (), min_value, max_value); 00135 for (unsigned int i=0; i<interest_points.points.size(); ++i) 00136 { 00137 const pcl::InterestPoint& interest_point = interest_points.points[i]; 00138 float image_x, image_y; 00139 range_image.getImagePoint (interest_point.x, interest_point.y, interest_point.z, image_x, image_y); 00140 widget->markPoint (image_x, image_y, wxGREEN_PEN, wxRED_BRUSH); 00141 //cout << "Marking point "<<image_x<<","<<image_y<<"\n"; 00142 } 00143 return widget; 00144 }