NumPy and OpenCV error: (-215:Assertion failed) ( (npoints >= 4) ||

Python, OpenCV I am trying to use this function

    retval, rvecc, tvecc = cv2.solvePnP(np.array(tnsPoints),
                                      np.array(imPoints),
                                      np.array(camera_matrix),
                                      np.array(dist))
and get an error

error: (-215:Assertion failed) ( (npoints >= 4) || (npoints == 3 && flags == SOLVEPNP_ITERATIVE && useExtrinsicGuess) || (npoints >= 3 && flags == SOLVEPNP_SQPNP) ) && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) in function 'solvePnPGeneric'

where tnsPoints is formed this way:

objPoints = objp = np.zeros((4*4,3), np.float32)
objp[:,:2] = np.mgrid[0:4,0:4].T.reshape(-1,2)

and imPoints is corners[1:] which I get from

    corners, ids, rejected = aruco.detectMarkers(imgGray, arucoDict, parameters=arucoParam)

It probably says that I don't have enough points to solvePnP, but here is corners:

(array([[[266., 629.],
        [334., 625.],
        [316., 665.],
        [245., 668.]]], dtype=float32), array([[[471., 620.],
        [538., 618.],
        [535., 656.],
        [464., 659.]]], dtype=float32), array([[[408., 555.],
        [465., 554.],
        [456., 583.],
        [395., 584.]]], dtype=float32), array([[[340., 503.],
        [392., 502.],
        [380., 525.],
        [325., 526.]]], dtype=float32), array([[[496., 501.],
        [547., 500.],
        [543., 522.],
        [491., 523.]]], dtype=float32))

where each array contains coordinates of the corners of an aruco-marker, there are 5 aruco-markers as you can see, so this should be enough.

So why is that saying I have <4 points, when I pass it 16?


Ответы (0 шт):