00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _MOVING_OBJECT_FILTER_H
00009 #define _MOVING_OBJECT_FILTER_H
00010
00011 #include <ros/ros.h>
00012 #include <pcl_ros/point_cloud.h>
00013
00014 #include <sensor_msgs/Image.h>
00015 #include <sensor_msgs/image_encodings.h>
00016 #include <cv_bridge/cv_bridge.h>
00017 #include <message_filters/subscriber.h>
00018 #include <message_filters/time_synchronizer.h>
00019 #include <message_filters/sync_policies/approximate_time.h>
00020
00021 #include <image_transport/image_transport.h>
00022 #include <image_transport/subscriber_filter.h>
00023
00024 #include <iostream>
00025 #include <stdio.h>
00026 #include <vector>
00027 #include <string>
00028 #include <ctime>
00029
00030 #include <opencv2/opencv.hpp>
00031 #include <opencv2/core/core.hpp>
00032 #include <opencv2/features2d/features2d.hpp>
00033 #include <opencv2/calib3d/calib3d.hpp>
00034 #include <opencv2/nonfree/nonfree.hpp>
00035 #include <opencv2/nonfree/features2d.hpp>
00036 #include <opencv2/imgproc/imgproc.hpp>
00037 #include <opencv2/highgui/highgui.hpp>
00038
00039 #include <eigen3/Eigen/Core>
00040 #include <eigen3/Eigen/Dense>
00041 #include <eigen3/Eigen/Eigen>
00042
00043 #include <pcl/point_cloud.h>
00044 #include <pcl/point_types.h>
00045 #include <pcl/common/time.h>
00046 #include <pcl/visualization/cloud_viewer.h>
00047 #include <pcl/ModelCoefficients.h>
00048 #include <pcl/sample_consensus/method_types.h>
00049 #include <pcl/sample_consensus/model_types.h>
00050 #include <pcl/segmentation/sac_segmentation.h>
00051 #include <pcl/segmentation/extract_clusters.h>
00052 #include <pcl/common/impl/angles.hpp>
00053 #include <pcl/filters/passthrough.h>
00054 #include <pcl/filters/voxel_grid.h>
00055 #include <pcl/filters/extract_indices.h>
00056 #include <pcl/filters/statistical_outlier_removal.h>
00057
00058 #include <pcl/pcl_base.h>
00059 #include <pcl/surface/concave_hull.h>
00060 #include <pcl/surface/convex_hull.h>
00061 #include <pcl/segmentation/extract_polygonal_prism_data.h>
00062 #include <cstring>
00063 #include <string>
00064
00065
00066 typedef pcl::PointXYZRGB point_type ;
00067 typedef pcl::PointCloud<pcl::PointXYZRGB> cloud_type ;
00068
00069 #define threshod_binary 30
00070 class MovingObjectFilter{
00071 public:
00072 MovingObjectFilter( int argc, char**argv ) ;
00073
00074 void processData( const cv::Mat & image, const cv::Mat &depth,
00075 float fx,float fy,
00076 float cx,float cy );
00077 std::string rgb_frame_id ;
00078 std::string depth_frame_id ;
00079 void setFrameId(std::string rgb_frame, std::string depth_frame) ;
00080
00081 private:
00082 ros::Publisher rgbPub_ ;
00083 ros::Publisher depthPub_ ;
00084 ros::Publisher cloudPub_ ;
00085
00086
00087
00088
00089
00090 cv::Mat lastImage ;
00091 cv::Mat lastDepth ;
00092 cv::Mat lastBlurImage ;
00093 cv::Mat lastFrame ;
00094 cv::Mat currentFrame ;
00095 cv::Mat Homography ;
00096 cv::Mat dynamicImage ;
00097
00098
00099
00100
00101 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud;
00102
00103
00104 cloud_type lastCloud ;
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 double threshod ;
00115 int num1 ;
00116
00117
00118 void computeHomography(cv::Mat &grayImage) ;
00119
00120
00121 void image_diff(const cv::Mat &image, cloud_type::ConstPtr cloud);
00122
00123
00124
00125
00126
00127
00128
00129 pcl::PointXYZ projectDepthTo3D(
00130 const cv::Mat & depthImage,
00131 float x, float y,
00132 float cx, float cy,
00133 float fx, float fy,
00134 bool smoothing,
00135 float maxZError = 0.02f );
00136
00137 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudFromDepthRGB(
00138 const cv::Mat & imageRgb,
00139 const cv::Mat & imageDepth,
00140 float cx, float cy,
00141 float fx, float fy,
00142 int decimation);
00143
00144
00145 cv::Mat pcl_segmentation( cloud_type::ConstPtr cloud , const cv::Mat &image , const cv::Mat &depthImage, float cx, float cy, float fx, float fy ) ;
00146 bool image_extract_cluster( cloud_type::ConstPtr cluster_cloud, cloud_type::ConstPtr cloud, const cv::Mat &image , float cx, float cy, float fx, float fy , int num , int j ) ;
00147 pcl::PointCloud<pcl::PointXYZRGB> objectFromOriginalCloud(cloud_type::ConstPtr clusterCloud, cloud_type::ConstPtr cloud);
00148 cv::Mat getDepth(cloud_type::ConstPtr cloud , const cv::Mat &depthImage, float cx, float cy, float fx, float fy) ;
00149 void getImage(cloud_type::ConstPtr cloud , const cv::Mat &image, float cx, float cy, float fx, float fy) ;
00150 cv::Mat bgrFromCloud(const pcl::PointCloud<pcl::PointXYZRGB> & cloud, bool bgrOrder);
00151 cv::Mat depthFromCloud(
00152 const pcl::PointCloud<pcl::PointXYZRGB> & cloud,
00153 float & fx,
00154 float & fy,
00155 bool depth16U);
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 };
00166 #endif