OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 05 Aug 2020 04:48:55 -0500How to give input parameters to triangulatePoints in python?http://answers.opencv.org/question/173969/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](http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#triangulatepoints). I find out P1 and P2 using [cv2.stereoRectify](http://docs.opencv.org/3.0-beta/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#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`?
Sun, 10 Sep 2017 14:51:44 -0500http://answers.opencv.org/question/173969/how-to-give-input-parameters-to-triangulatepoints-in-python/Answer by carl777 for <p>I want to find out 3D coordinates using stereo cameras. For that, I reached up to rectification of images but get stuck at <a href="http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#triangulatepoints">cv2.triangulatePoints</a>. I find out P1 and P2 using <a href="http://docs.opencv.org/3.0-beta/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#stereorectify">cv2.stereoRectify</a>. Now I have to put four parameters in <code>triangulatePoints</code> 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 <code>stereoRectify</code>? According to me, P1 and P2 should be same as none of input matrices are changing.
Now I want to know how to get <em>projPoints1</em> and <em>projPoints2</em> 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 <code>projPoints</code>?</p>
http://answers.opencv.org/question/173969/how-to-give-input-parameters-to-triangulatepoints-in-python/?answer=177659#post-id-177659You 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). Sun, 05 Nov 2017 12:41:28 -0600http://answers.opencv.org/question/173969/how-to-give-input-parameters-to-triangulatepoints-in-python/?answer=177659#post-id-177659Comment by friendCYQ for <p>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). </p>
http://answers.opencv.org/question/173969/how-to-give-input-parameters-to-triangulatepoints-in-python/?comment=233308#post-id-233308I use two cameras, the parameters of two cameras are K1,K2, so P1 = K1 * [I | 0], P2 = K2 * [R | T]？Wed, 05 Aug 2020 04:48:55 -0500http://answers.opencv.org/question/173969/how-to-give-input-parameters-to-triangulatepoints-in-python/?comment=233308#post-id-233308