Reputation: 73
I have 2 3D point clouds, stored in numpy.ndarrays, containing either 0 or 1 (Indication of a detected point or none). I would like to compute the affine transformation that converts the 'Test' array to the 'Reference' array.
I call the function like this:
import numpy as np
from cv2 import estimateAffine3D
[...] Read in the Arrays [...]
print(np.shape(Reference))
print(np.shape(Test))
AffineTransfMatrix = estimateAffine3D(Reference,Test)
And the Output I get is:
(132, 2055, 701)
(132, 2055, 701)
OpenCV Error: Assertion failed (count >= 0 && to.checkVector(3) == count) in estimateAffine3D, file /home/wenzlern/libraries/opencv/modules/calib3d/src/ptsetreg.cpp, line 513
Traceback (most recent call last):
File "/home/wenzlern/code/python/AbsorbtionSpecAnalysis/AlignEnergies.py", line 67, in <module>
estimateAffine3D(Reference,Test)
cv2.error: /home/wenzlern/libraries/opencv/modules/calib3d/src/ptsetreg.cpp:513: error: (-215) count >= 0 && to.checkVector(3) == count in function estimateAffine3D
I have tried playing around with the data type, using Reference/Test.astype('float32'), but could not change the result. The documentation does not seem to specify a specific format.(http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#estimateaffine3d).
Does anyone have an idea what could go wrong? Am I missing something, or calling the function wrong?
Thanks a lot, Nils
Upvotes: 3
Views: 3908
Reputation: 71
I've found that, with OpenCV 4.1.1, handing a numpy array with dtype that isn't np.int64 will also give a similar error message for estimateAffinePartial2D and estimateAffine2D:
error: (-215:Assertion failed) count >= 0 && to.checkVector(2) == count in function 'estimateAffinePartial2D'
Upvotes: 2
Reputation: 73
User Micka (in the comments to the question) had the right solution. The Array has to be passed in Nx3 format. In other words: The coordinates (x,y,z) of every point in the Point-Cloud are one 1x3 entry in the Nx3 matrix to be passed.
Thanks!
Upvotes: 1