dimatura / pypcd

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

Error when loading binary_compressed pcd file #21

Open bearpaw opened 5 years ago

bearpaw commented 5 years ago

Thanks for the great library! When I reload the binary_compressed PCD file, which is saved by pypcd from ros message, there is an error happening at https://github.com/dimatura/pypcd/blob/master/pypcd/pypcd.py#L683

I checked the code, and found out that when decoding the data at https://github.com/dimatura/pypcd/blob/master/pypcd/pypcd.py#L264 pc_data is created as a numpy array with shape (width, ). After decoding, len(pc_data) is also width instead number of points (width x height).

I am not sure whether this problem is caused by different python version. Actually, I tested on both python2.7 and python3.7 (with https://github.com/dimatura/pypcd/pull/9) and noticed the same error.

Any suggestions here?

yinxiaochuan commented 5 years ago

The metadata['width'] should be corrected with metadata['points'] in the parse_binary_compressed_pc_data function. https://github.com/dimatura/pypcd/blob/20b032bfc729dec853ac810bceeb360f78bdc1d6/pypcd/pypcd.py#L264 https://github.com/dimatura/pypcd/blob/20b032bfc729dec853ac810bceeb360f78bdc1d6/pypcd/pypcd.py#L268 The following line can be deleted. https://github.com/dimatura/pypcd/blob/20b032bfc729dec853ac810bceeb360f78bdc1d6/pypcd/pypcd.py#L510

bearpaw commented 5 years ago

Thanks @yinxiaochuan !