'error arising in solvepnp ; Assertion error OpenCV

This is done for pose estimation

After performing calibration, the output imgpoints and objpoints are being given as input to the solvePnP function as:

ret,revc,tvec= cv.solvePnP(temp1,temp2, cameraMatrix, dist)

Error which is arising is:

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 'cv::solvePnPGeneric'

adding a code snippet :

objpoints = np.ascontiguousarray(objpoints)

imgpoints = np.ascontiguousarray(imgpoints)

temp1 = np.stack(objpoints,axis=0)

temp2 = np.stack(imgpoints,axis=0)

ret,revc,tvec= cv.solvePnP(temp1,temp2, cameraMatrix, dist)

Can someone pls help with this ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source