From 242e64c08d83d70b7fa24e1c087647a2aeda6077 Mon Sep 17 00:00:00 2001 From: Christian Richardt Date: Wed, 13 May 2015 15:47:00 +0200 Subject: [PATCH] Fixed triangulation bug http://code.opencv.org/issues/4334. --- modules/calib3d/src/triangulate.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/calib3d/src/triangulate.cpp b/modules/calib3d/src/triangulate.cpp index 9f52b37..aa4b669 100644 --- a/modules/calib3d/src/triangulate.cpp +++ b/modules/calib3d/src/triangulate.cpp @@ -82,18 +82,18 @@ cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2, CvMat* projPoints1, CvMa CV_Error( CV_StsUnmatchedSizes, "Size of projection matrices must be 3x4" ); CvMat matrA; - double matrA_dat[24]; - matrA = cvMat(6,4,CV_64F,matrA_dat); + double matrA_dat[16]; + matrA = cvMat(4,4,CV_64F,matrA_dat); //CvMat matrU; CvMat matrW; CvMat matrV; //double matrU_dat[9*9]; - double matrW_dat[6*4]; + double matrW_dat[4*4]; double matrV_dat[4*4]; //matrU = cvMat(6,6,CV_64F,matrU_dat); - matrW = cvMat(6,4,CV_64F,matrW_dat); + matrW = cvMat(4,4,CV_64F,matrW_dat); matrV = cvMat(4,4,CV_64F,matrV_dat); CvMat* projPoints[2]; @@ -117,9 +117,8 @@ cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2, CvMat* projPoints1, CvMa y = cvmGet(projPoints[j],1,i); for( int k = 0; k < 4; k++ ) { - cvmSet(&matrA, j*3+0, k, x * cvmGet(projMatrs[j],2,k) - cvmGet(projMatrs[j],0,k) ); - cvmSet(&matrA, j*3+1, k, y * cvmGet(projMatrs[j],2,k) - cvmGet(projMatrs[j],1,k) ); - cvmSet(&matrA, j*3+2, k, x * cvmGet(projMatrs[j],1,k) - y * cvmGet(projMatrs[j],0,k) ); + cvmSet(&matrA, j*2+0, k, x * cvmGet(projMatrs[j],2,k) - cvmGet(projMatrs[j],0,k) ); + cvmSet(&matrA, j*2+1, k, y * cvmGet(projMatrs[j],2,k) - cvmGet(projMatrs[j],1,k) ); } } /* Solve system for current point */ -- 2.7.4