#include <RVC/RVC.h>
#include <iostream>
#include "IO/SavePointMap.h"
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
static pcl::PointCloud<pcl::PointXYZ>::Ptr PointMap2CloudPoint(
RVC::PointMap &pm) {
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());
cloud->height = pm.
GetSize().height;
cloud->is_dense = false;
cloud->resize(cloud->height * cloud->width);
const unsigned int pm_sz = cloud->height * cloud->width;
for (int i = 0; i < pm_sz; i++, pm_data += 3) {
cloud->points[i].x = pm_data[0];
cloud->points[i].y = pm_data[1];
cloud->points[i].z = pm_data[2];
}
return cloud;
}
int main(int argc, char **argv) {
size_t actual_size = 0;
SystemListDevices(devices, 10, &actual_size, RVC::SystemListDeviceType::All);
if (actual_size == 0) {
std::cout << "Can not find any RVC Camera!" << std::endl;
return -1;
}
if(devices[0].IsFirmwareMatch() == false){
std::cout << "device firmware mismatch, Please use RVCManager to upgrade the firmware" << std::endl;
return -1;
}
std::cout << "Failed to open camera! Please check whether the camera is connected and make sure it is not occupied and supports X1." << std::endl;
return -1;
}
std::cout << "RVC Camera capture successed!" << std::endl;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud = PointMap2CloudPoint(pm);
const size_t step = n_pts / 10000;
for (size_t i = 0; i < n_pts; i += step) {
printf("index: %d RVC::PointMap: (%.6f, %.6f, %.6f), pcd::PointCloud: (%.6f, %.6f, %.6f)\n", i,
pm_data[i * 3], pm_data[i * 3 + 1], pm_data[i * 3 + 2], cloud->points[i].x, cloud->points[i].y,
cloud->points[i].z);
}
} else {
std::cout << "RVC Camera capture failed!" << std::endl;
}
return 0;
}