I am trying to get a depth map in a non-calibrated way. I can get the fundamental matrix through various corresponding points from the SIFT method and cv2.findFundamentalMat . Then using cv2.stereoRectifyUncalibrated I can get the rectification matrix. Finally, I can use cv2.warpPerspective to fix and calculate the mismatch, but this does not lead to a good depth map. The values ββare very high, so I wonder if I need to use warpPerspective or if I need to calculate the rotation matrix from the homography matrix obtained with stereoRectifyUncalibrated .
So I'm not sure about the projective matrix with the case of the homography matrix obtained with stereoRectifyUncalibrated for straightening.
Code Part:
#Obtainment of the correspondent point with SIFT sift = cv2.SIFT() ###find the keypoints and descriptors with SIFT kp1, des1 = sift.detectAndCompute(dst1,None) kp2, des2 = sift.detectAndCompute(dst2,None) ###FLANN parameters FLANN_INDEX_KDTREE = 0 index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5) search_params = dict(checks=50) flann = cv2.FlannBasedMatcher(index_params,search_params) matches = flann.knnMatch(des1,des2,k=2) good = [] pts1 = [] pts2 = [] ###ratio test as per Lowe paper for i,(m,n) in enumerate(matches): if m.distance < 0.8*n.distance: good.append(m) pts2.append(kp2[m.trainIdx].pt) pts1.append(kp1[m.queryIdx].pt) pts1 = np.array(pts1) pts2 = np.array(pts2) #Computation of the fundamental matrix F,mask= cv2.findFundamentalMat(pts1,pts2,cv2.FM_LMEDS) # Obtainment of the rectification matrix and use of the warpPerspective to transform them... pts1 = pts1[:,:][mask.ravel()==1] pts2 = pts2[:,:][mask.ravel()==1] pts1 = np.int32(pts1) pts2 = np.int32(pts2) p1fNew = pts1.reshape((pts1.shape[0] * 2, 1)) p2fNew = pts2.reshape((pts2.shape[0] * 2, 1)) retBool ,rectmat1, rectmat2 = cv2.stereoRectifyUncalibrated(p1fNew,p2fNew,F,(2048,2048)) dst11 = cv2.warpPerspective(dst1,rectmat1,(2048,2048)) dst22 = cv2.warpPerspective(dst2,rectmat2,(2048,2048)) #calculation of the disparity stereo = cv2.StereoBM(cv2.STEREO_BM_BASIC_PRESET,ndisparities=16*10, SADWindowSize=9) disp = stereo.compute(dst22.astype(uint8), dst11.astype(uint8)).astype(np.float32) plt.imshow(disp);plt.colorbar();plt.clim(0,400)#;plt.show() plt.savefig("0gauche.png") #plot depth by using disparity focal length 'C1[0,0]' from stereo calibration and 'T[0]' the distance between cameras plt.imshow(C1[0,0]*T[0]/(disp),cmap='hot');plt.clim(-0,500);plt.colorbar();plt.show()
Here are the corrected images with the non- warpPerspective method (and warpPerspective ): 
Here are the corrected snapshots with the calibrated method: 
I donβt know how much the difference is so important between the two types of images ... and for a calibrated method it does not look aligned ... strange Map of non-calibrated method mismatch:

And the depth map is calculated using: C1[0,0]*T[0]/(disp) with T from stereoCalibrate but the values ββare very high ...
-------- EDIT LATER ------------
I tried to "mount" the recovery matrix ( [Devernay97] , [Garcia01] ) using the homography matrix obtained with "stereoRectifyUncalibrated", but the result is not very good ... Am I used correctly?
Y=np.arange(0,2048) X=np.arange(0,2048) (XX_field,YY_field)=np.meshgrid(X,Y)