Downsample pointcloud to 4096 points Modify based on the version from https://blog.csdn.net/SJTUzhou/article/details/122927787
(initPcd, desiredNumOfPoint, leftVoxelSize, rightVoxelSize)
| 13 | |
| 14 | |
| 15 | def pcd_downsample(initPcd, desiredNumOfPoint, leftVoxelSize, rightVoxelSize): |
| 16 | """ |
| 17 | Downsample pointcloud to 4096 points |
| 18 | Modify based on the version from https://blog.csdn.net/SJTUzhou/article/details/122927787 |
| 19 | """ |
| 20 | assert leftVoxelSize > rightVoxelSize, "leftVoxelSize should be larger than rightVoxelSize" |
| 21 | assert len(initPcd.points) > desiredNumOfPoint, "desiredNumOfPoint should be less than or equal to the num of points in the given point cloud." |
| 22 | if len(initPcd.points) == desiredNumOfPoint: |
| 23 | return initPcd |
| 24 | |
| 25 | pcd = deepcopy(initPcd) |
| 26 | pcd = pcd.voxel_down_sample(leftVoxelSize) |
| 27 | assert len(pcd.points) <= desiredNumOfPoint, "Please specify a larger leftVoxelSize." |
| 28 | pcd = deepcopy(initPcd) |
| 29 | pcd = pcd.voxel_down_sample(rightVoxelSize) |
| 30 | assert len(pcd.points) >= desiredNumOfPoint, "Please specify a smaller rightVoxelSize." |
| 31 | |
| 32 | pcd = deepcopy(initPcd) |
| 33 | midVoxelSize = (leftVoxelSize + rightVoxelSize) / 2. |
| 34 | pcd = pcd.voxel_down_sample(midVoxelSize) |
| 35 | while len(pcd.points) != desiredNumOfPoint: |
| 36 | if len(pcd.points) < desiredNumOfPoint: |
| 37 | leftVoxelSize = copy(midVoxelSize) |
| 38 | else: |
| 39 | rightVoxelSize = copy(midVoxelSize) |
| 40 | midVoxelSize = (leftVoxelSize + rightVoxelSize) / 2. |
| 41 | pcd = deepcopy(initPcd) |
| 42 | pcd = pcd.voxel_down_sample(midVoxelSize) |
| 43 | |
| 44 | return pcd |
| 45 | |
| 46 | |
| 47 | class LaserProjection(object): |
nothing calls this directly
no outgoing calls
no test coverage detected