I am trying to use this code to find camera position by locating flat image in the picture:
https://docs.opencv.org/3.3.1/d1/de0/tutorial_py_feature_homography.html
For this picture it works correctly:
and finds the pattern. I use cv2.projectPoints to draw image over background picture:
But sometimes solvePnP return crazy results, for example for this image:
I get crazy image position if I reproject the pattern:
For this case I've verified SIFT points, they look correctly and match:
I tried to use solvePnPRansac instead of solvePnP, but it doesnt help, estimated position is still stange. What might be the reason and how can I solve this problem?
Ok, I've managed to improve pose estimation in this case by setting distortion matrix to np.array([])
because I already rectify image before SIFT. Same applies to cv2.projectPoints
, there is no need to supply distortion coeffitients to this function also.