How to use OpenCV triangulation points

I am trying to get the OpenCV function to work triangulatePoints. I use a point-match function generated from an optical stream. I use two consecutive frames / positions from one moving camera.

At the moment, these are my steps:

The intrinsic properties are given and look as you would expect:

2.6551e+003  0.           1.0379e+003
0.           2.6608e+003  5.5033e+002
0.           0.           1.

Then I calculate two external matrices ([R | t]) based on (with high accuracy) GPS and camera position relative to GPS. Please note that GPS data uses a Cartesian coordinate system around the Netherlands, which uses meters as units of measurement (therefore no strange mathematical latitude is required). This gives the following matrices:

Camera extrinsic matrices

, :

projectionMat = intrinsics * extrinsics;

:

Projection matrices

,

(0, 0)...(1080, 1920)

+ .

(0 + flowY0, 0 + flowX0)...(1080 + flowYN, 1920 + flowXN)

, ( , OpenCV) triangulatePoints:

cv::triangulatePoints(projectionMat1, projectionMat2, imagePoints1, imagePoints2, outputPoints);

, outputPoints , (w) .

:

Output 1

, ( , X/Y/Z, X/Y/Z, ...), . , , 0,01. :

Output 2

( ), , .

, - -, . ? ?

, , GPS , , . , .

+7
2

triangulatePoints() , !

opencv doc :

3- ( ), a stereo camera. stereoRectify()

+1

, , , , , :

Respect to OpenCv Axis and rotation conventions

rotationMatrix0 = rotation_by_Y_Matrix_Camera_Calibration(camera_roll)*rotation_by_X_Matrix_Camera_Calibration(camera_pitch)  *rotation_by_Z_Matrix_Camera_Calibration(camera_yaw);



Mat3x3 Algebra::rotation_by_Y_Matrix_Camera_Calibration(double yaw)
{
    Mat3x3 matrix;
    matrix[2][2] = 1.0f;

    double sinA = sin(yaw), cosA = cos(yaw);
    matrix[0][0] = +cosA; matrix[0][1] = -sinA;
    matrix[1][0] = +sinA; matrix[1][1] = +cosA;



    return matrix;
}

Mat3x3 Algebra::rotation_by_X_Matrix_Camera_Calibration(double pitch)
{

    Mat3x3 matrix;
    matrix[1][1] = 1.0f;

    double sinA = sin(pitch), cosA = cos(pitch);

    matrix[0][0] = +cosA; matrix[0][2] = +sinA;
    matrix[2][0] = -sinA; matrix[2][2] = +cosA;


    return matrix;
}

Mat3x3 Algebra::rotation_by_Z_Matrix_Camera_Calibration(double roll)
{

    Mat3x3 matrix;
    matrix[0][0] = 1.0f;

    double sinA = sin(roll), cosA = cos(roll);
    matrix[1][1] = +cosA; matrix[1][2] = -sinA;
    matrix[2][1] = +sinA; matrix[2][2] = +cosA;



    return matrix;
}
0

Source: https://habr.com/ru/post/1669917/


All Articles