【发布时间】:2018-08-15 05:12:52
【问题描述】:
if triangles is None:
tridata = mesh['face'].data['vertex_indices']
print(tridata)
print(type(tridata))
print(tridata.dtype)
triangles = plyfile.make2d(tridata)
有一个错误:用一个序列设置一个数组元素。 我检查了tridata的类型:
[array([ 0, 5196, 10100], dtype=int32)
array([ 0, 2850, 10103], dtype=int32)
array([ 0, 3112, 10102], dtype=int32) ...
array([ 2849, 10076, 5728], dtype=int32)
array([ 2849, 10099, 8465], dtype=int32)
array([ 2849, 10098, 8602], dtype=int32)]
<class 'numpy.ndarray'>
object
ValueError:Error:setting an array element with a sequence.
不知道哪里错了? 有函数“make2d”的代码:
def make2d(array, cols=None, dtype=None):
'''
Make a 2D array from an array of arrays. The `cols' and `dtype'
arguments can be omitted if the array is not empty.
'''
if (cols is None or dtype is None) and not len(array):
raise RuntimeError("cols and dtype must be specified for empty "
"array")
if cols is None:
cols = len(array[0])
if dtype is None:
dtype = array[0].dtype
return _np.fromiter(array, [('_', dtype, (cols,))],
count=len(array))['_']
【问题讨论】:
-
这是一个包含数组的对象 dtype 数组。它不是二维数组。看起来错误出在
make2d方法中,但我对此一无所知。也许错误堆栈会有所帮助。或对此plyfile来源的引用。 -
感谢您的评论。我添加了make2d()的信息
-
我不得不花一些时间玩一下
fromiter的用法,以了解它可以使用或不能使用的内容。 -
我也在努力理解这个...
标签: python-3.x numpy ply-file-format