一、源码
opencailb的源代码
代码地址:https://github.com/PJLab-ADG/SensorsCalibration/blob/master/README.md
/** Copyright (C) 2021 by Autonomous Driving Group, Shanghai AI Laboratory* Limited. All rights reserved.* Yan Guohang <yanguohang@pjlab.org.cn>* Ouyang Jinhua <ouyangjinhua@pjlab.org.cn>*/
#pragma once#include <algorithm>
#include <iostream>
#include <memory>
#include <opencv2/opencv.hpp>
#include <string>#include <vector>#include "pcl/io/pcd_io.h"#define OVERLAP_FILTER_WINDOW 4
#define OVERLAP_DEPTH_TH 0.4 // 0.4mstruct Pt {cv::Point point;float dist;float z;float intensity;
};class Projector {
public:cv::Mat oriCloud;std::vector<float> intensitys;const float ROI[6] = {-4, 3.5, 5.0, 10.0, -2.1, 3.0};int point_size_ = 3;bool intensity_color_ = false;bool overlap_filter_ = false;void ROIFilter() {cv::Mat temp(cv::Size(oriCloud.cols, oriCloud.rows), CV_32FC1);int cnt = 0;for (int i = 0; i < oriCloud.cols; ++i) {float x = oriCloud.at<float>(0, i);float y = oriCloud.at<float>(1, i);float z = oriCloud.at<float>(2, i);if (x > ROI[0] && x < ROI[1] && y > ROI[2] && y < ROI[3] && z > ROI[4] &&z < ROI[5]) {temp.at<float>(0, cnt) = x;temp.at<float>(1, cnt) = y;temp.at<float>(2, cnt) = z;++cnt;}}oriCloud = temp.colRange(0, cnt);}void setPointSize(int size) { point_size_ = size; }void setDisplayMode(bool intensity_show) {intensity_color_ = intensity_show;}void setFilterMode(bool filter_mode) { overlap_filter_ = filter_mode; }bool loadPointCloud(pcl::PointCloud<pcl::PointXYZI> pcl) {oriCloud = cv::Mat(cv::Size(pcl.points.size(), 3), CV_32FC1);for (size_t i = 0; i < pcl.points.size(); ++i) {oriCloud.at<float>(0, i) = pcl.points[i].x;oriCloud.at<float>(1, i) = pcl.points[i].y;oriCloud.at<float>(2, i) = pcl.points[i].z;intensitys.push_bac