dimatura / pypcd

PCL pcd fileformat i/o in Python
Other
266 stars 196 forks source link

Unable to read binary format pcds #30

Open venkataksv opened 4 years ago

venkataksv commented 4 years ago

@dimatura , Thanks for putting together an amazing support for reading point cloud data in python. PCD is a widely used extension in the CV community. I was trying to leverage pypcd support to read a binary pcd but was unsuccessful in all my attempts. Can you please guide me on how to fix this issue to be able to read the pcd info ( binary/ascii ) successfully.

Attaching for reference of the error i had been receiving:

ValueError: field '__0000' occurs more than once

FYI: I was just using

 pc = pypcd.PointCloud.from_path("abc.pcd")

where abc.pcd was a binary format pcd.

TheLaas commented 3 years ago

I have the same problem. If the .pcd file have DATA ascii there is no problem but in the case DATA binary I get the same error.

TheLaas commented 3 years ago

So, my problem was that I had used the bag_to_pcd from the ros node pcl_ros . That script added two _ in FIELDS line in the header. Changing these two _ to something else made it work.

layssi commented 3 years ago

@TheLaas adding the two highlighted lines below fixes the issue

def parseheader(lines): """ Parse header of PCD files. """ metadata = {} for ln in lines: if ln.startswith('#') or len(ln) < 2: continue **ln = ln.replace('','s',1) ln = ln.replace('_','m',1)** print(ln) match = re.match('(\w+)\s+([\w\s.]+)', str(ln))

bobusfil commented 3 years ago

@TheLaas Could oyu please tell me how and where did you edit the code? I do No t know how to do this ..

CoolLoveBoy commented 2 years ago

So, my problem was that I had used the bag_to_pcd from the ros node pcl_ros . That script added two _ in FIELDS line in the header. Changing these two _ to something else made it work.

I have the same question. Could you have the answer to this question?

TheLaas commented 2 years ago

If I remember correctly I didn't change the code, I made a script that changed the output-files from bag_to_pcl. And replaced the _ from FIELDS there.

h-wata commented 2 years ago

@TheLaas adding the two highlighted lines below fixes the issue

def parse_header(lines): 
""" Parse header of PCD files. """ 
metadata = {} 
for ln in lines: 
if ln.startswith('#') or len(ln) < 2: continue 
ln = ln.replace('_','s',1)
ln = ln.replace('_','m',1)
print(ln) 
match = re.match('(\w+)\s+([\w\s.]+)', str(ln))

I think this is an addition to the above section, although it may have been resolved.

https://github.com/dimatura/pypcd/blob/20b032bfc729dec853ac810bceeb360f78bdc1d6/pypcd/pypcd.py#L77-L84

udnqv commented 2 years ago

Hi, if I change pypcd.py as you suggested above, I get the following error: image Has someone an idea how I can fix this issue? Thanks in advance!