代码
sacle=(max_point-min_point)/2
print('scale:{}'.format(sacle.shape))
- 其中,max_point和min_point都是1*3的矩阵。
输出
scale:(3,)
- 这时候再对这个scale进行操作就会报错:too many indices for array
sacle_x=sacle[0,0]
解决
- 很简单,在取值之前使用reshape函数把他reshape为一个矩阵就好了
sacle=(max_point-min_point)/2
print('scale:{}'.format(sacle.shape))
# print('sacle_x.shape:{}'.format(sacle_x.shape))
sacle_x=sacle.reshape(-1,3)[0,0]
scale:(3,)
scale_x:45.539733884999976
- 多提一句,numpy的矩阵运算不要太爽~
middle_point=np.mean([max_point,min_point],axis=0) #计算平均值
pointcloud=pointcloud/sacle_x #矩阵除以一个常数