Пример #1
0
 def test_downsample_empty(self):
     """Check that the downsample returns an empty pointcloud when passed an empty pointcloud"""
     pc_orig = cwipc.cwipc_from_points([], 0)
     pc_filtered = cwipc.cwipc_downsample(pc_orig, 1)
     self.assertEqual(len(pc_orig.get_points()), 0)
     self.assertEqual(len(pc_filtered.get_points()), 0)
     pc_orig.free()
     pc_filtered.free()
Пример #2
0
 def test_cwipc_from_points_empty(self):
     """Can we create a cwipc object from a empty list of values"""
     points = cwipc.cwipc_point_array(values=[])
     pc = cwipc.cwipc_from_points(points, 0)
     newpoints = pc.get_points()
     self.assertEqual(len(points), 0)
     self.assertEqual(len(newpoints), 0)
     pc.free()
Пример #3
0
 def test_cwipc_timestamp_cellsize(self):
     """Can we set and retrieve the timestamp and cellsize in a cwipc"""
     timestamp = 0x11223344556677
     pc = cwipc.cwipc_from_points([], timestamp)
     self.assertEqual(pc.timestamp(), timestamp)
     self.assertEqual(pc.cellsize(), 0)
     pc._set_cellsize(1.0)
     self.assertEqual(pc.cellsize(), 1.0)
     pc.free()
Пример #4
0
 def _ensure_cwipc(self):
     """Internal - make sure the cwipc is valid"""
     if self.cwipc: return
     tilenum = 1
     points = self.o3d.points
     colors = self.o3d.colors
     tiles = np.array([[tilenum]] * len(points))
     cwiPoints = np.hstack((points, colors, tiles))
     cwiPoints = list(
         map(
             lambda p: (p[0], p[1], p[2], int(p[3] * 255), int(p[4] * 255),
                        int(p[5] * 255), int(p[6])), list(cwiPoints)))
     self.cwipc = cwipc.cwipc_from_points(cwiPoints, 0)
Пример #5
0
 def test_cwipc_timestamp_cellsize(self):
     """Can we set and retrieve the timestamp and cellsize in a cwipc"""
     timestamp = 0x11223344556677
     pc = cwipc.cwipc_from_points([(0, 0, 0, 0, 0, 0, 1),
                                   (1, 0, 0, 0, 0, 0, 1),
                                   (2, 0, 0, 0, 0, 0, 1),
                                   (3, 0, 0, 0, 0, 0, 1)], timestamp)
     self.assertEqual(pc.timestamp(), timestamp)
     self.assertEqual(pc.cellsize(), 0)
     pc._set_cellsize(0.1)
     self.assertAlmostEqual(pc.cellsize(), 0.1)
     pc._set_cellsize(-1)
     self.assertAlmostEqual(pc.cellsize(), 1.0)
     pc.free()
Пример #6
0
 def test_cwipc_from_points(self):
     """Can we create a cwipc object from a list of values"""
     points = cwipc.cwipc_point_array(values=[(1, 2, 3, 0x10, 0x20, 0x30, 1), (4, 5, 6, 0x40, 0x50, 0x60, 2)])
     pc = cwipc.cwipc_from_points(points, 0)
     newpoints = pc.get_points()
     self.assertEqual(len(points), len(newpoints))
     for i in range(len(points)):
         op = points[i]
         np = newpoints[i]
         self.assertEqual(op.x, np.x)
         self.assertEqual(op.y, np.y)
         self.assertEqual(op.z, np.z)
         self.assertEqual(op.r, np.r)
         self.assertEqual(op.g, np.g)
         self.assertEqual(op.b, np.b)
         self.assertEqual(op.tile, np.tile)
     pc.free()
 def test_cwipc_codec_roundtrip_empty(self):
     """Check that we can roundtrip an empty pointcloud"""
     timestamp = 0x2233445566778899
     pc = cwipc.cwipc_from_points([], timestamp)
     encoder = _cwipc_codec.cwipc_new_encoder()
     decoder = _cwipc_codec.cwipc_new_decoder()
     encoder.feed(pc)
     data = encoder.get_bytes()
     self.assertNotEqual(len(data), 0)
     decoder.feed(data)
     pc2 = decoder.get()
     points = pc.get_points()
     points2 = pc2.get_points()
     self.assertEqual(len(points), 0)
     self.assertEqual(len(points2), 0)
     self.assertEqual(pc2.timestamp(), timestamp)
     encoder.free()
     decoder.free()
     pc.free()
     pc2.free()
Пример #8
0
 def _build_pointcloud(self):
     points = cwipc.cwipc_point_array(
         values=[(1, 2, 3, 0x10, 0x20, 0x30,
                  1), (4, 5, 6, 0x40, 0x50, 0x60, 2)])
     return cwipc.cwipc_from_points(points, 0)
Пример #9
0
 def from_points(klass, points):
     """Create Pointcloud from list of xyzrgbt tuples"""
     self = klass()
     pc = cwipc.cwipc_from_points(points, 0)
     self.cwipc = pc
     return self