Created
November 19, 2015 10:19
-
-
Save eprana/8abf86ebd324545dc3fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Retrieve pinhole from 'pinholeProjectionMatrix' attribute | |
| // Focal is the first element | |
| MDoubleArray intrinsicsArray; | |
| MVGMayaUtil::getDoubleArrayAttribute(camera.getDagPath().node(), "mvg_intrinsicParams", intrinsicsArray); | |
| LOG_INFO("mvg_intrinsicParams : ") | |
| LOG_INFO(intrinsicsArray) | |
| // Initialize K | |
| openMVG::Mat3 K; | |
| K(0,1) = 0.0; | |
| K(0,2) = 0.0; | |
| K(1,0) = 0.0; | |
| K(1,2) = 0.0; | |
| K(2,0) = 0.0; | |
| K(2,2) = 0.0; | |
| K(0,0) = intrinsicsArray[0]; | |
| K(1,1) = intrinsicsArray[0]; | |
| K(2,2) = 1.0; | |
| // First method : retrieve K and t | |
| MMatrix inclusiveMatrix = camera.getDagPath().inclusiveMatrix(); | |
| MTransformationMatrix transformMatrix(inclusiveMatrix); | |
| // Rotation matrix | |
| openMVG::Mat3 R; | |
| MMatrix rotationMatrix = transformMatrix.asRotateMatrix(); | |
| for(int i = 0; i < 3; ++i) | |
| { | |
| for(int j = 0; j < 3; ++j) | |
| R(i, j) = rotationMatrix[i][j]; | |
| } | |
| openMVG::Vec3 t; | |
| MVector translation = transformMatrix.translation(MSpace::kWorld); | |
| for(int i = 0; i < 3; ++i) | |
| t(i) = translation[i]; | |
| openMVG::Mat34 P; | |
| openMVG::P_From_KRt(K, R, t, &P); |
Author
Author
Mise à jour du code :
// Retrieve pinhole from 'pinholeProjectionMatrix' attribute
MDoubleArray intrinsicsArray;
MVGMayaUtil::getDoubleArrayAttribute(camera.getDagPath().node(), "mvg_intrinsicParams", intrinsicsArray);
LOG_INFO("mvg_intrinsicParams : ")
LOG_INFO(intrinsicsArray)
openMVG::Mat3 K;
K(0,0) = intrinsicsArray[0];
K(0,1) = 0.0;
K(0,2) = intrinsicsArray[1];
K(1,0) = 0.0;
K(1,1) = intrinsicsArray[0];
K(1,2) = intrinsicsArray[2];
K(2,0) = 0.0;
K(2,2) = 1.0;
LOG_INFO("### K ###")
LOG_INFO(K)
MMatrix inclusiveMatrix = camera.getDagPath().inclusiveMatrix();
LOG_INFO("### inclusiveMatrix ###")
LOG_INFO(inclusiveMatrix)
MTransformationMatrix transformMatrix(inclusiveMatrix);
openMVG::Mat3 R;
MMatrix rotationMatrix = transformMatrix.asRotateMatrix();
for(int m = 0; m < 3; ++m)
{
for(int j = 0; j < 3; ++j)
R(m, j) = rotationMatrix[m][j];
}
LOG_INFO("### R ###")
LOG_INFO(R)
MFnCamera fnCamera(camera.getDagPath());
openMVG::Vec3 C = TO_VEC3(fnCamera.eyePoint(MSpace::kWorld));
LOG_INFO("### C ###")
LOG_INFO(C)
openMVG::Vec3 t = -R * C;
LOG_INFO("### t ###")
LOG_INFO(t)
openMVG::Mat34 P;
openMVG::P_From_KRt(K, R, t, &P);
LOG_INFO("### P ###")
LOG_INFO(P)
projectiveCameras.push_back(P);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Voilà la fonction qu'on utilisait avant, avec la pinhole Camera de OpenMVG :
void triangulatePoint(const std::map<int, MPoint>& point2dPerCamera_CS,
MPoint& outTriangulatedPoint_WS)
{
size_t cameraCount = point2dPerCamera_CS.size();
assert(cameraCount > 1);
// prepare n-view triangulation data
openMVG::Mat2X imagePoints(2, cameraCount);
std::vectoropenMVG::Mat34 projectiveCameras;
}