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
00036 #ifndef _CAMERA_PROJECTION_H_
00037 #define _CAMERA_PROJECTION_H_
00038
00039 #define PFLN {printf("DEBUG PRINT FILE %s LINE %d\n",__FILE__,__LINE__);}
00040
00041
00044 #include <ros/ros.h>
00045
00046 #include <opencv2/imgproc/imgproc.hpp>
00047 #include <opencv2/highgui/highgui.hpp>
00048 #include <opencv2/core/core.hpp>
00049
00050 #include <sensor_msgs/PointCloud2.h>
00051 #include <pcl/ros/conversions.h>
00052 #include <pcl/point_cloud.h>
00053 #include <pcl/point_types.h>
00054 #include <pcl_ros/point_cloud.h>
00055 #include <tf/tf.h>
00056
00057
00058 #include "class_pinhole_projection.h"
00059 #include "polygon_intersection.h"
00060 #include <bo_polygon2d/polygon_boolean_operations.h>
00061 #include "distortion_correction.h"
00062 #include "projection_mesh.h"
00063
00064 typedef cv::Vec<unsigned char, 3> t_pixel;
00065
00069 class class_camera_projection: public class_pinhole_projection, public class_distortion_correction, public class_polygon_boolean_operations, virtual public class_camera_parameters, public class_projection_mesh
00070 {
00071
00072
00073
00074 public:
00075
00079 class_camera_projection(void){is_mapped_to_mesh=false; projection_name="unknown";};
00080
00084 ~class_camera_projection(void){};
00085
00095 int set_image(const cv::Mat* image, ros::Time time, std::string name="none");
00096
00105 int create_image_canvas(const cv::Mat* image, std::vector<pcl::PointXY>* pts);
00106 int create_image_canvas_for_known_camera(const cv::Mat* image, std::vector<pcl::PointXY>* pts, std::string name);
00107 int create_polygon_from_pts_list(const pcl::PointCloud<pcl::PointXYZ>* vertexes, pcl::PointCloud<pcl::PointXYZ>* vertices);
00108 float get_weight_for_pixel(int l, int c, double resolution_factor, float px, float py, float pz);
00109
00110 int set_vertex_chull(const pcl::PointCloud<pcl::PointXYZ>::Ptr vertexes);
00111
00112 void compute_projectable_pixels(void);
00113 int compute_pixel_list_to_vertex_list(pcl::ModelCoefficientsPtr coeff);
00114
00115
00116 int draw_pixels_vector(cv::Mat* image, std::vector<pcl::PointXY>* pts, const cv::Scalar color, int thickness=1);
00117 int draw_pixels_projectable(cv::Mat* image, pcl::PointCloud<pcl::PointXYZRGB>* pc, const cv::Scalar color, int thickness=1);
00118 int draw_pixels_vector_as_polyline(cv::Mat* image, std::vector<pcl::PointXY>* pts, const cv::Scalar color, int thickness);
00119
00120
00121 std::string projection_name;
00122 cv::Mat image_original;
00123 cv::Mat image_corrected;
00124 cv::Mat image_gui;
00125
00126
00127 cv::Mat image_gray;
00128 cv::Mat mask_canny;
00129 cv::Mat mask_grid;
00130 cv::Mat mask_intersection;
00131 cv::Mat mask_projectable_pixels;
00132
00133
00134 pcl::PointCloud<pcl::PointXYZ> vertex_canvas;
00135 pcl::PointCloud<pcl::PointXYZ> vertex_chull;
00136 pcl::PointCloud<pcl::PointXYZ> vertex_intersection;
00137 std::vector<pcl::PointXY> pixels_intersection;
00138 pcl::PointCloud<pcl::PointXYZRGB> pixels_projectable;
00139 pcl::PointCloud<pcl::PointXYZRGB> vertex_projectable;
00140
00141
00142
00143
00144 pcl::PointCloud<pcl::PointXYZRGB> pixel_list;
00145 pcl::PointCloud<pcl::PointXYZRGB> vertex_list;
00146 std::vector<float> face_weight;
00147
00148 bool is_mapped_to_mesh;
00149
00150
00151
00152
00153 private:
00154 };
00155
00156 #endif
00157