Ask Your Question

Revision history [back]

triangulatepoints returns very bad results

Hello, I'm new in CV and trying to calculate 3D-Coordinates of a point with a stereo-setup. I don't get useful results from my code and the posts/questions of other users also didn't helped me. I did the following things:

Step 1: Calibrate both cameras individually with a chessboard to get the intrinsic (camera matrix and distortion coefficients) parameters. I used the cv::calibrateCamera() function which returned an reprojection error smaller than 0.2 for both cameras.

Step2: Stereo Calibrate of the Setup with a chessboard to get the rotation and translation matrix. I checked the result. The Error was very small and the T-Vector values are correlated to the physical setup (about 12.5 cm Basline).

Step 3: Getting the projection matrices for both cameras P1 and P2 using the cv::stereoRectify() function.

Now i want to triangulate.

  1. I took a capture with both cameras and remapped the captures using the function cv::initUndistortRectifyMap() and cv::remap().

  2. I detected the centre of the ball. In the left picture it was on pixel: x=343/y=272 and on the right picture it was on x=296/y=272. With these inputs i was trying the get 3D-coordinates of the point with the following code:

    int co1[] = {343,272};

    Mat point1(2, 1, CV_32FC1, co1);

    int co2[] = {296,272};

    Mat point2(2, 1, CV_32FC1, co2);

    Mat points4D;

    triangulatePoints(P1,P2,point1,point2,points4D);

for this input i got the following output from triangulatepoints: [5.21432042e-001, 4.01907146e-001, -7.52714634e-001, -1.1737522e-018]

The result also doesn't change if I change the pixel-coordinates manually. Can you tell me what i am doing wrong? Do i have a logical error about how triangulatePoints works?The actual position of the point is about [0;0;125]cm if you take the left camera as origin.

PS:I could give you a dropbox-link to my images and my camera parameters but right now im not allowed to post links

Ty for your help

triangulatepoints returns very bad results

Hello, I'm new in CV and trying to calculate 3D-Coordinates of a point with a stereo-setup. I don't get useful results from my code and the posts/questions of other users also didn't helped me. I did the following things:

Step 1: Calibrate both cameras individually with a chessboard to get the intrinsic (camera matrix and distortion coefficients) parameters. I used the cv::calibrateCamera() function which returned an reprojection error smaller than 0.2 for both cameras.

Step2: Stereo Calibrate of the Setup with a chessboard to get the rotation and translation matrix. I checked the result. The Error was very small and the T-Vector values are correlated to the physical setup (about 12.5 cm Basline).

Step 3: Getting the projection matrices for both cameras P1 and P2 using the cv::stereoRectify() function.

Now i want to triangulate.

  1. I took a capture with both cameras and remapped the captures using the function cv::initUndistortRectifyMap() and cv::remap().

  2. I detected the centre of the ball. You can find the images and my Calibration results under this link: Dropbox Link

In the left picture it was on pixel: x=343/y=272 and on the right picture it was on x=296/y=272. With x=296/y=272.With these inputs i was trying the get 3D-coordinates of the point with the following code:

int co1[] = {343,272};

{343,272}; Mat point1(2, 1, CV_32FC1, co1);

co1); int co2[] = {296,272};

{296,272}; Mat point2(2, 1, CV_32FC1, co2);

co2) Mat points4D;

triangulatePoints(P1,P2,point1,point2,points4D);

points4D; triangulatePoints(P1,P2,point1,point2,points4D);

for this input i got the following output from triangulatepoints: [5.21432042e-001, 4.01907146e-001, -7.52714634e-001, -1.1737522e-018]

The result also doesn't change if I change the pixel-coordinates manually. Can you tell me what i am doing wrong? Do i have a logical error about how triangulatePoints works?The actual position of the point is about [0;0;125]cm if you take the left camera as origin.

PS:I could give you a dropbox-link to my images and my camera parameters but right now im not allowed to post links

Ty for your help