1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #pragma once
- #include "thread/singleton.h"
- #include <pcl/point_cloud.h>
- #include <pcl/point_types.h>
- #include <pcl/filters/passthrough.h>
- #include <pcl/filters/statistical_outlier_removal.h>
- class singleWheelDetector : public Singleton<singleWheelDetector> {
- friend class Singleton<singleWheelDetector>;
- public:
- struct WheelDetectResult {
- bool haveCloud = false;
- bool segmentOk = false;
- bool detectOk = false;
- pcl::PointXYZ center;
- float confidence = 0;
- float theta = 0;
- void reset() {
- haveCloud = false;
- segmentOk = false;
- detectOk = false;
- center.x = 0;
- center.y = 0;
- center.z = 0;
- confidence = 0;
- theta = 0;
- }
- std::string info() {
- char str[512];
- sprintf(str, "x: %.3f, y: %.3f, z: %.3f, theta: %.3f", center.x, center.y, center.z, theta);
- return str;
- }
- };
- singleWheelDetector &operator=(const singleWheelDetector &) = delete;
- ~singleWheelDetector() override = default;
- // 检测底盘z方向值,去中心,使用mat加速
- bool detect(pcl::PointCloud<pcl::PointXYZ>::Ptr in_cloud_ptr, pcl::PointCloud<pcl::PointXYZ>::Ptr out_cloud_ptr,
- WheelDetectResult &result);
- protected:
- // 父类的构造函数必须保护,子类的构造函数必须私有。
- singleWheelDetector();
- private:
- std::vector<double> line_;
- };
|