probreg CPD注册函数不能用于python注册



我试图注册两个点云与问题,但我得到这个错误。谁能告诉我为什么这是。创建的输入可能不是float32?

这是我的代码:

import copy
import numpy as np
import open3d as o3
from probreg import cpd
# load source and target point cloud
source = o3.io.read_point_cloud('ovslam1.pcd')
target = copy.deepcopy('bim1.pcd')
# compute cpd registration
tf_param, _, _ = cpd.registration_cpd(source, target)
result = copy.deepcopy(source)
result.points = tf_param.transform(result.points)
# draw result
source.paint_uniform_color([1, 0, 0])
target.paint_uniform_color([0, 1, 0])
result.paint_uniform_color([0, 0, 1])
o3.visualization.draw_geometries([source, target, result])

这是我的错误:

$ python3 cpd.py 
Traceback (most recent call last):
File "cpd.py", line 19, in <module>
tf_param, _, _ = cpd.registration_cpd(source, target)
File "/home/joe/.local/lib/python3.8/site-packages/probreg/cpd.py", line 281, in registration_cpd
return cpd.registration(cv(target),
File "/home/joe/.local/lib/python3.8/site-packages/probreg/cpd.py", line 84, in registration
res = self._initialize(target)
File "/home/joe/.local/lib/python3.8/site-packages/probreg/cpd.py", line 117, in _initialize
sigma2 = self._squared_kernel_sum(self._source, target)
File "/home/joe/.local/lib/python3.8/site-packages/probreg/math_utils.py", line 25, in squared_kernel_sum
return _math.squared_kernel(x, y).sum() / (x.shape[0] * x.shape[1] * y.shape[0])
TypeError: squared_kernel(): incompatible function arguments. The following argument types are supported:
1. (arg0: numpy.ndarray[numpy.float32[m, n]], arg1: numpy.ndarray[numpy.float32[m, n]]) -> numpy.ndarray[numpy.float32[m, n]]
Invoked with: array([[  2.63302541,  -2.03959942, -21.31122589],
[  2.77799726,  -2.06889749, -21.75521278],
[  2.83439279,  -1.22657204, -21.78207016],
...,
[ -3.28682041,  -0.90619814,  16.61546516],
[ -3.30297685,  -0.90664768,  16.64566422],
[ -3.24951434,  -0.87377918,  16.65137482]]), array('bim1.pcd', dtype='<U8')

可以了

import copy
import numpy as np
import open3d as o3
from probreg import cpd
from probreg import gmmtree
# load source and target point cloud
source = o3.io.read_point_cloud('ovslam1.pcd')
target = o3.io.read_point_cloud('bim1.pcd')
source = source.voxel_down_sample(voxel_size=0.05)
target = target.voxel_down_sample(voxel_size=0.05)
# compute cpd registration
tf_param, _, _ = cpd.registration_cpd(source, target)
result = copy.deepcopy(source)
result.points = tf_param.transform(result.points)
source = result.points

tf_param, _ = gmmtree.registration_gmmtree(source, target)
result = copy.deepcopy(source)
result.points = tf_param.transform(result.points)

# draw result
source.paint_uniform_color([1, 0, 0])
target.paint_uniform_color([0, 1, 0])
result.paint_uniform_color([0, 0, 1])
o3.visualization.draw_geometries([source, target, result])

最新更新