File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 19
19
try :
20
20
from StringIO import StringIO , BytesIO
21
21
except ImportError :
22
- from io import BytesIO
22
+ from io import BytesIO , StringIO
23
23
24
24
HAS_SENSOR_MSGS = True
25
25
try :
@@ -317,6 +317,12 @@ def point_cloud_from_buffer(buf):
317
317
return pc
318
318
319
319
320
+ def point_cloud_from_string (string ):
321
+ with StringIO (string ) as fileobj :
322
+ pc = point_cloud_from_fileobj (fileobj )
323
+ return pc
324
+
325
+
320
326
def point_cloud_to_fileobj (pc , fileobj , data_compression = None ):
321
327
""" Write pointcloud as .pcd to fileobj.
322
328
If data_compression is not None it overrides pc.data.
@@ -745,9 +751,17 @@ def from_path(fname):
745
751
def from_fileobj (fileobj ):
746
752
return point_cloud_from_fileobj (fileobj )
747
753
754
+ @staticmethod
755
+ def from_string (string ):
756
+ return point_cloud_from_string (string )
757
+
748
758
@staticmethod
749
759
def from_buffer (buf ):
750
- return point_cloud_from_buffer (buf )
760
+ try :
761
+ return point_cloud_from_buffer (buf )
762
+ except TypeError :
763
+ # The old method could handle strings. The new one should also be able to.
764
+ return PointCloud .from_string (buf )
751
765
752
766
@staticmethod
753
767
def from_array (arr ):
You can’t perform that action at this time.
0 commit comments