organized point

	// Setup the cloud
	using PointType = pcl::PointXYZ;
	using CloudType = pcl::PointCloud<PointType>;
	CloudType::Ptr cloud(new CloudType);

	// Make the cloud a 10x10 grid
	cloud->height = 10;
	cloud->width = 10;
	cloud->is_dense = true;
	cloud->resize(cloud->height * cloud->width);

	// Output the (0,0) point
	std::cout << (*cloud)(0, 0) << std::endl;

	// Set the (0,0) point
	PointType p; p.x = 1; p.y = 2; p.z = 3;
	(*cloud)(0, 0) = p;

	// Confirm that the point was set
	std::cout << (*cloud)(0, 0) << std::endl;

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段代码用于将深度图转换为点云。以下是每一行代码的作用: 1. `def create_point_cloud_from_depth_image(depth, camera, organized=True):`:定义一个函数,该函数接受深度图、相机参数和一个布尔型变量是否有序的标志。 2. `assert(depth.shape[0] == camera.height and depth.shape[1] == camera.width)`:检查深度图的形状是否与相机的高度和宽度一致,如果不一致则抛出异常。 3. `xmap = np.arange(camera.width)`:创建一个长度为相机宽度的一维数组,其中包含从0到相机宽度-1的整数。 4. `ymap = np.arange(camera.height)`:创建一个长度为相机高度的一维数组,其中包含从0到相机高度-1的整数。 5. `xmap, ymap = np.meshgrid(xmap, ymap)`:将xmap和ymap数组转换为二维矩阵,其中xmap矩阵的每一行都是xmap数组的一个副本,ymap矩阵的每一列都是ymap数组的一个副本。 6. `points_z = depth`:将深度图赋值给points_z变量。 7. `points_x = (xmap - camera.cx) * points_z / camera.fx`:根据相机内参计算每个像素点的X坐标。 8. `points_y = (ymap - camera.cy) * points_z / camera.fy`:根据相机内参计算每个像素点的Y坐标。 9. `cloud = np.stack([points_x, points_y, points_z], axis=-1)`:将X、Y和Z坐标组合成一个点云矩阵,其中每行包含一个点的X、Y和Z坐标。 10. `if not organized: cloud = cloud.reshape([-1, 3])`:如果点云不是有序的,则将其重新组织为无序的形式。有序的点云是指点云按照行列顺序排列,无序的点云是指点云按照无序的顺序排列。 11. `return cloud`:返回点云矩阵。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值