最近搞了个奥比中光的深度摄像头,需要通过摄像头获取点云数据,先后查阅了很多资料。
自己写了几个功能的C++程序:
1.采集点云数据(我这里设置的是0.8米以内,具体数值可以自己更改)
2.在控制台输入!号,设置采集数据存放的根目录
3.在控制台按空格键,输入在根目录下要新建的用户文件夹
4.在控制台按回车键,保存当前点云数据
5.在depth显示窗口按Esc退出程序
/*************************
OpenNI2 Point-cloud collect program
Author: Danqing Miao, 2018.11
*************************/
#include <stdlib.h>
#include <iostream>
#include <string>
#include <fstream>
#include <direct.h>
#include "OpenNI.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
//获取键盘输入
#include <conio.h>
#include <Windows.h>
using namespace std;
using namespace cv;
using namespace openni;
typedef struct {
float x;
float y;
float z;
} vector3f;
#define SAMPLE_READ_WAI