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
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef SHAPE_RECONSTRUCTION_RANGE_IMAGE_PLANAR
00049 #define SHAPE_RECONSTRUCTION_RANGE_IMAGE_PLANAR
00050
00051 #include <map>
00052 #include <pcl/range_image/range_image_planar.h>
00053
00054 #include <opencv2/core/core.hpp>
00055
00056
00057 namespace shape_reconstruction {
00058
00066 class RangeImagePlanar : public pcl::RangeImagePlanar {
00067 public:
00068 typedef boost::shared_ptr<shape_reconstruction::RangeImagePlanar> Ptr;
00069 typedef boost::shared_ptr<const shape_reconstruction::RangeImagePlanar> ConstPtr;
00070
00071 RangeImagePlanar () : pcl::RangeImagePlanar(), img_coord_to_point_idx(NULL) {
00072 delete img_coord_to_point_idx;
00073 }
00074
00076 virtual ~RangeImagePlanar () {
00077 }
00078
00079 template <typename PointCloudType> void
00080 createFromPointCloudWithFixedSizeAndStorePoints (const PointCloudType& point_cloud,
00081 int di_width, int di_height, float di_center_x, float di_center_y,
00082 float di_focal_length_x, float di_focal_length_y,
00083 const Eigen::Affine3f& sensor_pose,
00084 CoordinateFrame coordinate_frame=CAMERA_FRAME, float noise_level=0.0f,
00085 float min_range=0.0f);
00086
00087 template <typename PointCloudType> void
00088 doZBufferAndStorePoints (const PointCloudType& point_cloud,
00089 float noise_level, float min_range,
00090 int& top, int& right, int& bottom, int& left);
00091
00092
00093
00095
00096 template <typename PointCloudType> void
00097 computeZandMatchingPoints (const PointCloudType& point_cloud,
00098
00099 float min_range,
00100 const cv::Mat& matching_im, const float matching_im_min_range,
00101 pcl::PointIndicesPtr& matching_indices,
00102 pcl::PointIndicesPtr& matching_indices_in_matching_im,
00103 pcl::PointIndicesPtr& indices_to_remove,
00104 int height, int width);
00105
00106 template <typename PointCloudType> void
00107 matchPointCloudAndImage (const PointCloudType& point_cloud,
00108 int di_width, int di_height,
00109 float di_center_x, float di_center_y,
00110 float di_focal_length_x, float di_focal_length_y,
00111 const Eigen::Affine3f& sensor_pose,
00112 CoordinateFrame coordinate_frame,
00113 const cv::Mat& matching_im, const float matching_im_min_range,
00114 pcl::PointIndicesPtr& matching_indices,
00115 pcl::PointIndicesPtr& matching_indices_in_matching_im,
00116 pcl::PointIndicesPtr& indices_to_remove,
00117 float min_range=0.0f
00118 );
00119
00120
00121 bool getPointIndex(const int& x, const int& y, int& idx) const {
00122 assert (img_coord_to_point_idx != NULL);
00123 int arrayPos = y*width + x;
00124 idx = img_coord_to_point_idx[arrayPos];
00125 if (idx == 0)
00126 return false;
00127
00128 idx--;
00129 return true;
00130 }
00131
00132 void setPointIndex(const int& x, const int& y, const int& idx) {
00133 assert (img_coord_to_point_idx != NULL);
00134 int arrayPos = y*width + x;
00135
00136
00137
00138 img_coord_to_point_idx[arrayPos] = idx+1;
00139 }
00140
00141 void resetPointIndex(const int& width, const int& height) {
00142 unsigned int size = width*height;
00143 delete img_coord_to_point_idx;
00144 img_coord_to_point_idx = new int[size];
00145
00146 ERASE_ARRAY (img_coord_to_point_idx, size);
00147 }
00148
00149
00150
00151
00152 int* img_coord_to_point_idx;
00153
00154 };
00155
00156 }
00157
00158 #endif