#pragma once #include "opencv2/core/core.hpp" #include #include #include #include // opencv 用于图像数据读取与处理 #include #include #include // 使用Eigen的Geometry模块处理3d运动 #include #include // pcl #include #include #include #include #include #include #include #include // boost.format 字符串处理 #include using namespace std; using namespace pcl; // 定义点云类型 typedef PointCloud PointCloudXYZ; class DepthProcessor{ private: cv::Mat imgDepth; // or pointCloud detect by lidar public: //控制显示和打印 bool bPrintObjs = false; bool bViewRGB = false; bool bViewCloud = false; //点云显示对象 visualization::PCLVisualizer::Ptr pcdViewer; //最近物体信息 double dist, max_x, max_y, min_x, min_y; std::string label; // 创建点云对象 PointCloudXYZ::Ptr cloud; //相机参数 double fx, fy, cx, cy; //相机初始化高度 float camHigh; DepthProcessor(); bool obstacleDetect(const cv::Mat depthMat, const Eigen::Affine3f& transform); PointCloudXYZ::Ptr depth2Cloud(const cv::Mat depthMat, int startRow, int endRow); bool camHighInit(const cv::Mat depthMat, const Eigen::Affine3f& transform); static PointCloudXYZ::Ptr downsampling(const PointCloudXYZ::Ptr& pointCloud, float leaf); static PointCloudXYZ::Ptr axisFilter(const PointCloudXYZ::Ptr& pointCloud, const double&thre_low, const double& thre_high, const string& field, const bool& flag_in); PointCloudXYZ::Ptr delGround(const PointCloudXYZ::Ptr& pointCloud); static void calHistogram(const PointCloudXYZ::Ptr& pointCloud, float& maxY, std::vector>& histogram); static void radiusSearch(const PointCloudXYZ::Ptr& pointCloud, const PointXYZ& queryPoint, const float& radius, std::vector& indResults); double IOU(double max_x1,double min_x1,double max_y1,double min_y1,double max_x2,double min_x2,double max_y2,double min_y2); void calHistogramZ(const PointCloudXYZ::Ptr &pointCloud, std::vector>& histogram); };