SRUtils.h
Go to the documentation of this file.
00001 /*
00002  * SRUtils.h
00003  *
00004  *      Author: roberto
00005  *
00006  * This is a modified implementation of the method for online estimation of kinematic structures described in our paper
00007  * "Online Interactive Perception of Articulated Objects with Multi-Level Recursive Estimation Based on Task-Specific Priors"
00008  * (Martín-Martín and Brock, 2014) and the extension to segment, reconstruct and track shapes introduced in our paper
00009  * "An Integrated Approach to Visual Perception of Articulated Objects" (Martín-Martín, Höfer and Brock, 2016)
00010  * This implementation can be used to reproduce the results of the paper and to be applied to new research.
00011  * The implementation allows also to be extended to perceive different information/models or to use additional sources of information.
00012  * A detail explanation of the method and the system can be found in our paper.
00013  *
00014  * If you are using this implementation in your research, please consider citing our work:
00015  *
00016 @inproceedings{martinmartin_ip_iros_2014,
00017 Title = {Online Interactive Perception of Articulated Objects with Multi-Level Recursive Estimation Based on Task-Specific Priors},
00018 Author = {Roberto {Mart\'in-Mart\'in} and Oliver Brock},
00019 Booktitle = {Proceedings of the IEEE/RSJ International Conference on Intelligent Robots and Systems},
00020 Pages = {2494-2501},
00021 Year = {2014},
00022 Location = {Chicago, Illinois, USA},
00023 Note = {http://www.robotics.tu-berlin.de/fileadmin/fg170/Publikationen_pdf/martinmartin_ip_iros_2014.pdf},
00024 Url = {http://www.robotics.tu-berlin.de/fileadmin/fg170/Publikationen_pdf/martinmartin_ip_iros_2014.pdf},
00025 Projectname = {Interactive Perception}
00026 }
00027 
00028 @inproceedings{martinmartin_hoefer_iros_2016,
00029 Title = {An Integrated Approach to Visual Perception of Articulated Objects},
00030 Author = {Roberto {Mart\'{i}n-Mart\'{i}n} and Sebastian H\"ofer and Oliver Brock},
00031 Booktitle = {Proceedings of the IEEE International Conference on Robotics and Automation},
00032 Pages = {5091 - 5097},
00033 Year = {2016},
00034 Doi = {10.1109/ICRA.2016.7487714},
00035 Location = {Stockholm, Sweden},
00036 Month = {05},
00037 Note = {http://www.redaktion.tu-berlin.de/fileadmin/fg170/Publikationen_pdf/martin_hoefer_15_iros_sr_opt.pdf},
00038 Url = {http://www.redaktion.tu-berlin.de/fileadmin/fg170/Publikationen_pdf/martin_hoefer_15_iros_sr_opt.pdf},
00039 Url2 = {http://ieeexplore.ieee.org/xpl/articleDetails.jsp?tp=&arnumber=7487714},
00040 Projectname = {Interactive Perception}
00041 }
00042  * If you have questions or suggestions, contact us:
00043  * roberto.martinmartin@tu-berlin.de
00044  *
00045  * Enjoy!
00046  */
00047 
00048 #ifndef SR_UTILS_H_
00049 #define SR_UTILS_H_
00050 
00051 #include "shape_reconstruction/RangeImagePlanar.h"
00052 #include "omip_common/OMIPUtils.h"
00053 #include "omip_common/OMIPTypeDefs.h"
00054 
00055 #include <opencv2/core/core.hpp>
00056 #include <camera_info_manager/camera_info_manager.h>
00057 #include <pcl/range_image/range_image_planar.h>
00058 #include <pcl/filters/extract_indices.h>
00059 #include <pcl/common/transforms.h>
00060 #include <pcl/search/search.h>
00061 #include <pcl/search/organized.h>
00062 #include <pcl/search/kdtree.h>
00063 #include <pcl/filters/extract_indices.h>
00064 #include <pcl/filters/voxel_grid.h>
00065 #include <pcl/kdtree/kdtree_flann.h>
00066 #include <pcl/filters/radius_outlier_removal.h>
00067 #include <pcl/filters/approximate_voxel_grid.h>
00068 #include <pcl/features/normal_3d_omp.h>
00069 #include <pcl/point_types.h>
00070 #include <pcl/io/pcd_io.h>
00071 #include <pcl/kdtree/kdtree_flann.h>
00072 #include <pcl/features/normal_3d.h>
00073 #include <pcl/surface/gp3.h>
00074 #include <pcl/io/vtk_lib_io.h>
00075 #include <boost/circular_buffer.hpp>
00076 
00077 namespace omip
00078 {
00079 
00080 // Comment or uncomment this line to test the downsampling (WIP -> RangeImagePlanar?)
00081 //#define DOWNSAMPLING
00082 
00083 #ifdef DOWNSAMPLING
00084 #define IMG_WIDTH 320
00085 #define IMG_HEIGHT 240
00086 #else
00087 #define IMG_WIDTH 640
00088 #define IMG_HEIGHT 480
00089 #endif
00090 
00091 #define NUM_SCALES 3
00092 
00093 typedef pcl::PointXYZRGB SRPoint;
00094 typedef pcl::PointCloud<SRPoint> SRPointCloud;
00095 
00096 void RangeImagePlanar2DepthMap(const pcl::RangeImagePlanar::Ptr& rip, cv::Mat& depth_map_mat);
00097 
00098 void RangeImagePlanar2PointCloud(const pcl::RangeImagePlanar::Ptr& rip, SRPointCloud::Ptr& pc);
00099 
00100 void OrganizedPC2DepthMap(const SRPointCloud::Ptr organized_pc, cv::Mat& depth_map_mat);
00101 void OrganizedPC2DepthMapAlternative(const SRPointCloud::Ptr organized_pc, const cv::Ptr<cv::Mat>& depth_map_mat_ptr);
00102 void OrganizedPC2ColorMap(const SRPointCloud::Ptr organized_pc, cv::Mat& color_map_mat);
00103 
00104 
00105 void UnorganizedPC2DepthMap(const SRPointCloud::Ptr& organized_pc,
00106                             const int& width,
00107                             const int& height,
00108                             cv::Mat& depth_map,
00109                             ::shape_reconstruction::RangeImagePlanar::Ptr& rip,
00110                             const float& noiseLevel=0.f,
00111                             const float& minRange=0.5f);
00112 
00113 void DepthImage2CvImage(const cv::Mat& depth_image_raw, sensor_msgs::ImagePtr& depth_msg);
00114 
00115 void Image8u2Indices(const cv::Mat& image_8u, pcl::PointIndices::Ptr indices_ptr);
00116 
00117 void Indices2Image8u(const std::vector<int>& indices, cv::Mat& image_8u);
00118 
00119 void drawOptFlowMap(const cv::Mat& flow, cv::Mat& cflowmap, int step,double scale, const cv::Scalar& color);
00120 
00121 void drawOpticalFlowModule(const cv::Mat& optical_flow, cv::Mat& optical_flow_module);
00122 
00123 void fillNaNsCBF(const sensor_msgs::Image& color_img, const cv::Mat& depth_img, cv::Mat& filled_depth_img, ros::Time query_time);
00124 
00125 void removeDuplicateIndices(std::vector<int>& vec);
00126 
00127 /*
00128 % In-paints the depth image using a cross-bilateral filter. The operation
00129 % is implemented via several filterings at various scales. The number of
00130 % scales is determined by the number of spacial and range sigmas provided.
00131 % 3 spacial/range sigmas translated into filtering at 3 scales.
00132 %
00133 % Args:
00134 %   imgRgb - the RGB image, a uint8 HxWx3 matrix
00135 %   imgDepthAbs - the absolute depth map, a HxW double matrix whose values
00136 %                 indicate depth in meters.
00137 %   spaceSigmas - (optional) sigmas for the spacial gaussian term.
00138 %   rangeSigmas - (optional) sigmas for the intensity gaussian term.
00139 %
00140 % Returns:
00141 %    imgDepthAbs - the inpainted depth image.
00142 */
00143 cv::Mat fill_depth_cbf(cv::Mat imgRgb, cv::Mat imgDepthAbs, double* spaceSigmas, double* rangeSigmas);
00144 
00145 // Filters the given depth image using a Cross Bilateral Filter.
00146 //
00147 // Args:
00148 //   depth - HxW row-major ordered matrix.
00149 //   intensity - HxW row-major ordered matrix.
00150 //   mask - HxW row-major ordered matrix.
00151 //   result - HxW row-major ordered matrix.
00152 //   sigma_s - the space sigma (in pixels)
00153 //   sigma_r - the range sigma (in intensity values, 0-1)
00154 void cbf(uint8_t* depth, uint8_t* intensity, bool* mask, uint8_t* result, double* sigma_s, double* sigma_r);
00155 
00156 }
00157 
00158 #endif /*SR_UTILS_H_*/
00159 


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:36:32