# How to give input parameters to triangulatePoints in python?

I want to find out 3D coordinates using stereo cameras. For that, I reached up to rectification of images but get stuck at cv2.triangulatePoints. I find out P1 and P2 using cv2.stereoRectify. Now I have to put four parameters in triangulatePoints functions which are projMatr1 (P1), projMatr2 (P2), projPoints1 and projPoints2. Now my first doubt is if P1 and P2 remain same for every pair of images as we are giving input Camera matrices, rotation and translation matrices in stereoRectify? According to me, P1 and P2 should be same as none of input matrices are changing. Now I want to know how to get projPoints1 and projPoints2 to get 3D coordinates. For example, if I know the pixel values of any point A in rectified left image as (Xl,Yl) and same Point A in right image as (Xr,Yr) can I put projPoints1 = (Xl,Yl) and projPoints2 = (Xr,Yr) in triangulatePoints? If not then how to get these projPoints?

edit retag close merge delete

Sort by » oldest newest most voted

You don't really need to compute rectification transforms (using stereoRectify) unless you want to align epipolar lines and/or do stereo matching. You can just compose the projection matrices from calibration result as (P0 = K [ I | 0 ], P1 = K [ R | T ] ) where I, K, R, & T are the identity matrix, intrinsic camera, rotation and translation matrices respectively. Now you only need the corresponding point from both images (left and right).

more

I use two cameras, the parameters of two cameras are K1,K2, so P1 = K1 * [I | 0], P2 = K2 * [R | T]？

( 2020-08-05 04:48:55 -0500 )edit

Official site

GitHub

Wiki

Documentation