Considerably simplified
parent
7ec056f5cc
commit
59ac8b3f5b
|
@ -31,29 +31,11 @@ using namespace std;
|
||||||
using namespace gtsam;
|
using namespace gtsam;
|
||||||
|
|
||||||
// See http://www.cs.cornell.edu/~snavely/bundler/bundler-v0.3-manual.html
|
// See http://www.cs.cornell.edu/~snavely/bundler/bundler-v0.3-manual.html
|
||||||
// Special version of Cal3Bundler so that default constructor = 0,0,0
|
// as to why so much gymnastics is needed to massage the initial estimates and
|
||||||
// This is only used in localCoordinates below
|
// measurements: basically, Snavely does not use computer vision conventions
|
||||||
struct CeresCalibration : public Cal3Bundler {
|
// but OpenGL conventions :-(
|
||||||
CeresCalibration(double f = 0, double k1 = 0, double k2 = 0, double u0 = 0,
|
|
||||||
double v0 = 0)
|
|
||||||
: Cal3Bundler(f, k1, k2, u0, v0) {}
|
|
||||||
CeresCalibration(const Cal3Bundler& cal) : Cal3Bundler(cal) {}
|
|
||||||
CeresCalibration retract(const Vector& d) const {
|
|
||||||
return CeresCalibration(fx() + d(0), k1() + d(1), k2() + d(2), u0(), v0());
|
|
||||||
}
|
|
||||||
Vector3 localCoordinates(const CeresCalibration& T2) const {
|
|
||||||
return T2.vector() - vector();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace gtsam {
|
typedef PinholeCamera<Cal3Bundler> Camera;
|
||||||
template <>
|
|
||||||
struct traits<CeresCalibration> : public internal::Manifold<CeresCalibration> {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// With that, camera below behaves like Snavely's 9-dim vector
|
|
||||||
typedef PinholeCamera<CeresCalibration> Camera;
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
// parse options and read BAL file
|
// parse options and read BAL file
|
||||||
|
@ -79,8 +61,8 @@ int main(int argc, char* argv[]) {
|
||||||
size_t i = 0, j = 0;
|
size_t i = 0, j = 0;
|
||||||
BOOST_FOREACH (const SfM_Camera& camera, db.cameras) {
|
BOOST_FOREACH (const SfM_Camera& camera, db.cameras) {
|
||||||
// readBAL converts to GTSAM format, so we need to convert back !
|
// readBAL converts to GTSAM format, so we need to convert back !
|
||||||
Camera ceresCamera(gtsam2openGL(camera.pose()), camera.calibration());
|
Pose3 openGLpose = gtsam2openGL(camera.pose());
|
||||||
Vector9 v9 = Camera().localCoordinates(ceresCamera);
|
Vector9 v9; v9 << Pose3::Logmap(openGLpose), camera.calibration().vector();
|
||||||
initial.insert(C(i++), v9);
|
initial.insert(C(i++), v9);
|
||||||
}
|
}
|
||||||
BOOST_FOREACH (const SfM_Track& track, db.tracks) {
|
BOOST_FOREACH (const SfM_Track& track, db.tracks) {
|
||||||
|
|
Loading…
Reference in New Issue