1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- //
- // Created by huli on 2021/3/24.
- //
- #ifndef NNXX_TESTS_POINT3D_TOOL_H
- #define NNXX_TESTS_POINT3D_TOOL_H
- #include <pcl/point_cloud.h>
- #include <pcl/point_types.h>
- #include <vector>
- #include <opencv4/opencv2/opencv.hpp>
- #include "log/log.h"
- class Point3D_tool
- {
- public:
- static bool WriteTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud);
- static bool WriteTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZI>::Ptr &cloud);
- static bool ReadTxtCloud(const std::string &file, pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud);
- template <typename PclPoint>
- static int getMinRect(cv::RotatedRect &rect, pcl::shared_ptr<pcl::PointCloud<PclPoint>> &clouds);
- // template <typename PclPoint>
- // static int getMinRect(cv::RotatedRect &rect, pcl::shared_ptr<pcl::PointCloud<PclPoint>> &points) {
- static int getRectCloud(cv::RotatedRect &rect, pcl::shared_ptr<pcl::PointCloud<pcl::PointXYZ>> &points, float z_value = 0, int numbers = 100);
- template <typename PclPoint>
- static int getRectCloud(pcl::shared_ptr<pcl::PointCloud<PclPoint>> &clouds, pcl::shared_ptr<pcl::PointCloud<pcl::PointXYZ>> &points, float z_value = 0, int numbers = 100);
- static void getRectWidthlength(cv::RotatedRect &rect, double &width, double &length);
- private:
- static bool string2PointXYZ(const std::string &str, pcl::PointXYZ &point) {
- std::istringstream iss;
- iss.str(str);
- float value;
- float data[3];
- for (int i = 0; i < 3; ++i) {
- if (iss >> value) {
- data[i] = value;
- } else {
- return false;
- }
- }
- point.x = data[0];
- point.y = data[1];
- point.z = data[2];
- return true;
- }
- };
- #endif //NNXX_TESTS_POINT3D_TOOL_H
|