vs2019+opencv配置方法:https://blog.youkuaiyun.com/y18771025420/article/details/110373449
vs2019+pcl配置方法:https://blog.youkuaiyun.com/y18771025420/article/details/110517524
参考文章:
https://blog.youkuaiyun.com/stq054188/article/details/106408454
彩色图 + 深度图 = 点云
// C++ 标准库
#include <iostream>
#include <string>
using namespace std;
// OpenCV 库
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
// PCL 库
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_types.h>
// 定义点云类型
typedef pcl::PointXYZRGBA PointT;
typedef pcl::PointCloud<PointT> PointCloud;
// 相机内参
const double camera_factor = 1000;
const double camera_cx = 325.5;
const double camera_cy = 253.5;
const double camera_fx = 518.0;
const double camera_fy = 519.0;
// 主函数
int main(int argc, char ** argv)
{
// 图像矩阵
cv::Mat rgb, depth;
// 使用cv::imread()来读取图像
// rgb 图像是8UC3的彩色图像
// depth 是16UC1的单通道图像,注意flags设置-1,表示读取原始数据不做任何修改
rgb = cv::imread("C:\\Users\\Administrator\\Desktop\\color.png");
depth = cv::imread("C:\\Users\\Administrator\\Desktop\\depth.png", -1);
// 点云变量
// 使用智能指针,创建一个空点云。这种指针用完会自动释放。
PointCloud::Ptr cloud(new PointCloud);
// 遍历深度图
for (int m = 0; m < depth.rows; m++)
for (int n =