127 std::shared_ptr<ZEDCamera> pExampleZEDCam1 = globals::g_pCameraHandler->GetZED(CameraHandler::ZEDCamName::eHeadMainCam);
129 pExampleZEDCam1->Start();
152 std::future<bool> fuDepthCopyStatus;
153 std::future<bool> fuPointCloudCopyStatus;
156 if (pExampleZEDCam1->GetUsingGPUMem())
159 fuDepthCopyStatus = pExampleZEDCam1->RequestDepthCopy(cvGPUDepthFrame1);
160 fuPointCloudCopyStatus = pExampleZEDCam1->RequestPointCloudCopy(cvGPUPointCloud1);
165 fuDepthCopyStatus = pExampleZEDCam1->RequestDepthCopy(cvDepthFrame1);
166 fuPointCloudCopyStatus = pExampleZEDCam1->RequestPointCloudCopy(cvPointCloud1);
170 if (fuDepthCopyStatus.get() && fuPointCloudCopyStatus.get())
172 if (pExampleZEDCam1->GetUsingGPUMem())
175 cvGPUDepthFrame1.
download(cvDepthFrame1);
176 cvGPUPointCloud1.
download(cvPointCloud1);
180 if (!cvDepthFrame1.
empty())
196 static pcl::PointCloud<pcl::PointXYZ>::Ptr pclCloud(
new pcl::PointCloud<pcl::PointXYZ>());
197 static pcl::PointCloud<pcl::PointXYZ>::Ptr pclFilteredPointCloud(
new pcl::PointCloud<pcl::PointXYZ>);
198 static pcl::PointCloud<pcl::PointXYZ>::Ptr pclDownsampledPointCloud(
new pcl::PointCloud<pcl::PointXYZ>);
199 static pcl::visualization::PCLVisualizer::Ptr pclViewer;
204 pclViewer.reset(
new pcl::visualization::PCLVisualizer(
"Depth Point Cloud"));
205 pclViewer->setBackgroundColor(0, 0, 0);
206 pclViewer->addPointCloud<pcl::PointXYZ>(pclDownsampledPointCloud,
"depth_cloud");
207 pclViewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2,
"depth_cloud");
208 pclViewer->addCoordinateSystem(20.0);
209 pclViewer->initCameraParameters();
213 pclCloud->width = cvPointCloud1.
cols;
214 pclCloud->height = cvPointCloud1.
rows;
215 pclCloud->is_dense =
false;
216 pclCloud->points.resize(pclCloud->width * pclCloud->height);
219 for (
int nY = 0; nY < cvPointCloud1.
rows; ++nY)
221 for (
int nX = 0; nX < cvPointCloud1.
cols; ++nX)
224 size_t siIDx = nY * cvPointCloud1.
cols + nX;
229 pclCloud->points[siIDx].x = cvPoint[0];
230 pclCloud->points[siIDx].y = cvPoint[1];
231 pclCloud->points[siIDx].z = cvPoint[2];
236 pclCloud->points[siIDx].x = std::numeric_limits<float>::quiet_NaN();
237 pclCloud->points[siIDx].y = std::numeric_limits<float>::quiet_NaN();
238 pclCloud->points[siIDx].z = std::numeric_limits<float>::quiet_NaN();
244 std::vector<int> vIndices;
245 pcl::removeNaNFromPointCloud(*pclCloud, *pclFilteredPointCloud, vIndices);
247 pcl::VoxelGrid<pcl::PointXYZ> pclVoxelGrid;
248 pclVoxelGrid.setInputCloud(pclFilteredPointCloud);
249 pclVoxelGrid.setLeafSize(VOXEL_GRID_LEAF_SIZE, VOXEL_GRID_LEAF_SIZE, VOXEL_GRID_LEAF_SIZE);
250 pclVoxelGrid.filter(*pclDownsampledPointCloud);
252 pclViewer->updatePointCloud(pclDownsampledPointCloud,
"depth_cloud");
253 pclViewer->spinOnce(10);
271 network::g_bRoveCommUDPStatus =
false;
272 network::g_bRoveCommTCPStatus =
false;
275 globals::g_pCameraHandler->StopAllCameras();
void DepthMouseCallback(int nEvent, int nX, int nY, int nFlags, void *pUserData)
Mouse callback function for depth image clicks.
Definition ZEDCAMPointCloudTest.hpp:52
void PointCloudMouseCallback(int nEvent, int nX, int nY, int nFlags, void *pUserData)
Mouse callback function for point cloud clicks.
Definition ZEDCAMPointCloudTest.hpp:82