MarkHedleyJones / blender-pcd-io

Import and Export Point Cloud Data files from Blender 2.8+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ascii format not correctly detected in the header

dn9090 opened this issue · comments

Hi there!

Currently I'm sitting on a issue that I can't reproduce in other libraries like Open3d. For some reason the assertion in line 68 fails:

Python: Traceback (most recent call last):
  File "C:\Users\nagel\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\io_pcd\__init__.py", line 64, in execute
    return import_pcd.import_pcd(context, self.filepath)
  File "C:\Users\nagel\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\io_pcd\import_pcd.py", line 263, in import_pcd
    pcd_data = load_pcd_file(filepath)
  File "C:\Users\nagel\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\io_pcd\import_pcd.py", line 236, in load_pcd_file
    header = read_header(file)
  File "C:\Users\nagel\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\io_pcd\import_pcd.py", line 93, in read_header
    return validated_header(header)
  File "C:\Users\nagel\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\io_pcd\import_pcd.py", line 68, in validated_header
    assert header["DATA"] in ["ascii", "binary", "binary_compressed"]
AssertionError

I have printed out what the value of header["DATA"] is and the value is ascii.
The header in my file looks like this (encoded in ASCII):

VERSION .7
FIELDS x y z
SIZE 4 4 4
TYPE F F F
COUNT 1 1 1
WIDTH 564744
HEIGHT 1
VIEWPOINT -1.490116E-07 -0.0006223619 -1.316695 1 0 0 0
POINTS 564744
DATA ascii

I have also attached a sample file below. Can you reproduce the issue? Thanks.

pointcloud-4-0-0.txt

It looks like the importer does not ignore the line endings in the transformation str(x) which causes problems on windows where the CR of the CR+LF endings is included in the string.

Hi @dn9090,
Thank's very much for opening an issue and especially for including a PCD file to help reproduce the issue.
With you're help I've created at patch in #15 that I will release soon.

A new version of the addon has been released. Please let me know if you have any issues with it.
Thanks again.

I have a PLY file which I converted in to PCD using cloud compare, but this addon failed to load it in blender,

this is the error

Python: Traceback (most recent call last):
File "C:\Users\Qaisar Rehman\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_pcd_init_.py", line 79, in execute
import_pcd.import_pcd(context, path)
File "C:\Users\Qaisar Rehman\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_pcd\import_pcd.py", line 266, in import_pcd
pcd_data = load_pcd_file(filepath)
File "C:\Users\Qaisar Rehman\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_pcd\import_pcd.py", line 246, in load_pcd_file
points = parsers[header["DATA"]](file, header, struct_format)
File "C:\Users\Qaisar Rehman\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_pcd\import_pcd.py", line 208, in parse_binary_points
return [
File "C:\Users\Qaisar Rehman\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_pcd\import_pcd.py", line 209, in
(struct.unpack(struct_format, file.read(bytes_per_point)))
struct.error: unpack requires a buffer of 22 bytes

I will appreciate any help! thanks

@qaisarehman Could you open a new/separate issue for this please?