How can get get camera pose from SFMExample_bal.cpp?
Issue #332
resolved
I'd like to write the optimization result to a .ply file and display it. So I need to first acquire camera pose from result, whose type is Value. However the type Value confuses me a lot, because I cannot set a correct symbol to index the poses. I've successfully acquired the 3D points in the following way:
/* Optimize the graph and print results */
Values result;
try {
LevenbergMarquardtParams params;
params.setVerbosity("ERROR");
LevenbergMarquardtOptimizer lm(graph, initial, params);
result = lm.optimize();
} catch (exception& e) {
cout << e.what();
}
cout << "final error: " << graph.error(result) << endl;
result.print();
for ( int i = 0; i < 7; i++)
{
Eigen::Vector3d t;
t = result.at<Point3>(P(i));
std::cout << t.transpose() << std::endl;
}
I wonder how I can index the pose part of each camera? Below is my result displayed in the terminal by using function print(), and the dataset I use is dubrovnik-3-7-18-pre.txt.
final error: 0.00234484790701
Values with 10 values:
Value c0: (N5gtsam13PinholeCameraINS_11Cal3BundlerEEE) .poseR:
[
0.999977223274 -0.00230514620207 0.00634344022609;
-0.00244250266406 -0.999760860789 0.0217314384163;
0.00629182911806 -0.0217464373149 -0.999743719835
]
[-0.748902674644, 0.237838387455, 1.70883983936]';.calibration.K[1430.03198; -0.000332702018; -4.86536183e-05; 0; 0];
Value c1: (N5gtsam13PinholeCameraINS_11Cal3BundlerEEE) .poseR:
[
0.93896213 0.303743412 -0.161524173;
0.303059168 -0.952516099 -0.0294656097;
-0.16280436 -0.0212842897 -0.986428771
]
[0.694744511, 0.0768199095, 1.42674212]';.calibration.K[1356.06343; 0.481177863; -0.764335134; 0; 0];
Value c2: (N5gtsam13PinholeCameraINS_11Cal3BundlerEEE) .poseR:
[
0.94461052 -0.0569333385 0.323217514;
-0.161836169 -0.937580044 0.307819291;
0.285517111 -0.343077624 -0.894861846
]
[-9.47394625, -8.44266019, 6.21279028]';.calibration.K[1568.54046; 12.6307594; -73.0687803; 0; 0];
Value p0: (N5gtsam6Point3E) [-12.0558961, 12.8386795, -41.0994235]'
Value p1: (N5gtsam6Point3E) [5.73030717, 0.482589835, -21.8320539]'
Value p2: (N5gtsam6Point3E) [9.89975696, 3.18013164, -23.5054797]'
Value p3: (N5gtsam6Point3E) [9.91790401, 2.99110771, -23.5137072]'
Value p4: (N5gtsam6Point3E) [11.1660295, 19.7648731, -45.2522347]'
Value p5: (N5gtsam6Point3E) [-0.366083041, 2.33137686, -21.7413939]'
Value p6: (N5gtsam6Point3E) [5.82827434, 11.0966556, -39.6923671]'
-12.0558961 12.8386795 -41.0994235
5.73030717 0.482589835 -21.8320539
9.89975696 3.18013164 -23.5054797
9.91790401 2.99110771 -23.5137072
11.1660295 19.7648731 -45.2522347
-0.366083041 2.33137686 -21.7413939
5.82827434 11.0966556 -39.6923671
num cameras: 3
Comments (2)
-
-
- changed status to resolved
Please re-open if still a problem
- Log in to comment
In Values.h:
Please resolve this issue if it works.