Thread: [cgkit-user] Pointcloud error
Brought to you by:
mbaas
From: Nick D. <nic...@gm...> - 2012-09-30 10:22:20
|
Hey, I tried loading a ptc with the example code: from cgkit.cgtypes import * from cgkit import pointcloud import numpy ptc = pointcloud.open("test.ptc", "r", "3delight") buf = numpy.zeros(shape=(5, 7+ptc.datasize), dtype=numpy.float32) ptc.readDataPoints(5, buf) But I get this error: Traceback (most recent call last): File "C:\ndPtc\ndPtc.py", line 7, in <module> ptc.readDataPoints(7, buf) File "C:\Python27\lib\site-packages\cgkit\pointcloud.py", line 325, in readDat aPoints pntPtr = _arrayPointer(buffer, pntStride*numPoints) File "C:\Python27\lib\site-packages\cgkit\pointcloud.py", line 83, in _arrayPo inter raise TypeError("Unsupported array type (data pointer is not an int)") TypeError: Unsupported array type (data pointer is not an int) Any ideas? I have no problems with this: for p in ptc.iterPoints(): print p But it seems using Numpy arrays will give me a speed boast. Cheers, Nick Deboar |
From: Matthias B. <mat...@gm...> - 2012-09-30 13:41:43
|
Hi Nick, On 30.09.12 11:22, Nick Deboar wrote: > ptc = pointcloud.open("test.ptc", "r", "3delight") > buf = numpy.zeros(shape=(5, 7+ptc.datasize), dtype=numpy.float32) > ptc.readDataPoints(5, buf) > > But I get this error: > > Traceback (most recent call last): > File "C:\ndPtc\ndPtc.py", line 7, in <module> > ptc.readDataPoints(7, buf) > File "C:\Python27\lib\site-packages\cgkit\pointcloud.py", line 325, in readDat > aPoints > pntPtr = _arrayPointer(buffer, pntStride*numPoints) > File "C:\Python27\lib\site-packages\cgkit\pointcloud.py", line 83, in _arrayPo > inter > raise TypeError("Unsupported array type (data pointer is not an int)") > TypeError: Unsupported array type (data pointer is not an int) > > Any ideas? Is this on a 64bit system? Can you run the following snippet in a Python shell: >>> import numpy >>> buf = numpy.zeros(shape=(5, 7), dtype=numpy.float32) >>> type(buf.__array_interface__.get("data")[0]) <type 'int'> My suspicion is that you will get a long type instead of an int. If that's the case and you are in a position to change the cgkit code, you could try to change line 82 in pointcloud.py from if type(data[0]) is not int: to if type(data[0]) not in [int, long]: Let me know if that fixes the problem. Cheers, - Matthias - |