Compute projection matrix function (Feature #549)


Added by Georgios Petrou over 14 years ago. Updated over 14 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:- % Done:

0%

Category:imgproc, video
Target version:-
Difficulty: Pull request:

Description

I have made a small function that computes the projection matrix based on the type P = [R|T] to use with the cvTriangulatePoints function.

CvMat *cvGetProjectionMatrix(CvMat *intrinsicMatrix,
CvMat *rotationMatrix,
CvMat *translationVector) {
CvMat *cameraMatrix = cvCreateMat(3,4,CV_32FC1);
CvMat *rotationTranslationMatrix = cvCreateMat(3,4,CV_32FC1);

for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
cvmSet( rotationTranslationMatrix, i, j, cvmGet( rotationMatrix, i, j ) );
}
for(int i=0; i<3; i++)            
cvmSet( rotationTranslationMatrix, i, 3, cvmGet( translationVector, i, 0 ) );
cvMatMul(intrinsicMatrix,rotationTranslationMatrix,projectionMatrix);
[[CvMat]] *projectionMatrix64 = cvCreateMat(3,4,CV_64FC1); cvConvert(projectionMatrix,projectionMatrix64);
cvReleaseMat(&rotationTranslationMatrix);
cvReleaseMat(&projectionMatrix);

return projectionMatrix64;
}


Associated revisions

Revision 2304d536
Added by Andrey Kamaev about 12 years ago

Merge pull request #549 from asmorkalov:android_mips_static_build_fix

History

Updated by Vadim Pisarevsky over 14 years ago

with the newly added hconcat() (horizontal concatenation) and vconcat() (vertical concatenation) the function becomes trivial (in the new C++ API):

Mat P;
hconcat(R, T, P);
P = cameraMatrix * P;

so, there is no need, perhaps, in a separate function

  • Status changed from Open to Done
  • (deleted custom field) set to wontfix

Also available in: Atom PDF