Compute projection matrix function (Feature #549)
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
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