# Output of triangulation is flat (z value near 0)

Hello

i try to treangulte points with stereo cameras. The output has always a z value near 0.

triangulatePoints Input (and projectionMatrix1,2):

Mat projPoints1 [380, 181, 365; 130, 229, 238]
Mat projPoints2 [305, 104, 291; 165, 265, 273]


triangulatePoints Output:

Mat points4D
[0.8609779430113023, 0.3817725390523637, 0.7116126550869795;
0.5086202250537253, 0.9242461720198268, 0.7025628565436543;
0.002441490946153247, 0.002977891704646576, 0.00220898865581931;
0.004060472421340527, 0.003142306987421266, 0.002825260058571214]


StereoCalibrate Output

Rotation Matrix
[0.9999959644741038, 0.002840952105795514, 5.161359762791157e-006;
-0.002840952056622284, 0.9999959644423463, -9.509666388605118e-006;
-5.188355440578255e-006, 9.494964836467141e-006, 0.9999999999414633]
Translation Vector
[-89.9571208702335;
21.25152405495268;
0.001574274342767844]


StereoRectify Output

projectionMatrix1
[1, 0, 65.52658225987989, 0;
0, 1, -65.26453360733174, 0;
0, 0, 1, 0]
projectionMatrix2
[1, 0, 65.52658225987989, -92.43327794900694;
0, 1, -65.26453360733174, 0;
0, 0, 1, 0]


Calibrate Function

public void calibrateSingle (final Size patternSize, final Mat[] images) {

List<Mat> objectPoints = new ArrayList<Mat>();

List<Mat> imagePoints1 = new ArrayList<Mat>();
final MatOfPoint2f corners1 = new MatOfPoint2f();
if ( !getCorners(images[0], corners1, patternSize) ) {
return;
}

List<Mat> imagePoints2 = new ArrayList<Mat>();
final MatOfPoint2f corners2 = new MatOfPoint2f();
if ( !getCorners(images[1], corners2, patternSize) ) {
return;
}

final Mat cameraMatrix1 = new Mat();
final Mat cameraMatrix2 = new Mat();
final Mat distCoeff1 = new Mat();
final Mat distCoeff2 = new Mat();

Calib3d.stereoCalibrate(
objectPoints,
imagePoints1,
imagePoints2,
cameraMatrix1,
distCoeff1,
cameraMatrix2,
distCoeff2,
images[0].size(),
rotation,
translation,
essential,
fundament
);

Calib3d.stereoRectify(
cameraMatrix1,
distCoeff1,
cameraMatrix2,
distCoeff2,
images[0].size(),
rotation,
translation,
rectification1,
rectification2,
projectionMatrix1,
projectionMatrix2,
dtdMatrix

);
}


Triangulate Function

public Mat triangulatePoints (final Mat projPoints1, final Mat projPoints2) {
final Mat points4D = new Mat();
Calib3d.triangulatePoints(projectionMatrix1, projectionMatrix2, projPoints1, projPoints2, points4D);
return points4D;
}


I try many tings with using Calib3d.correctMatches and calibrate the Cameras before stereo Calibrate and then use this distCoffs and cameraMatrix. But i get every time the same result. If i came closer to the objects wiht the cameras. The triangele go smaler and closer to the Point 0,0,0.

I try many things the last days and have no more ideas.

Thanks for help.

edit retag close merge delete