Home

Awesome

Momo

Install

Requirements

installation

Usage

Limitations

Example

#include <momo/motion_optimizer.hpp>
#include <momo/commons.hpp>

Eigen::Vector3d match_to_viewing_ray(cv::Point a, Eigen::Matrix3d intrinsics){
    Eigen::Vector3d a_hom(a.x,a.y,1.);
    Eigen::Vector3d out=intrinsics.inverse()*a_hom;
    out.normalize()
    return out;
}
int main(int argc, char* argv[])
{
// dummy defines
// REPLACE F,CU,CV BY CAMERA INTRINSICS
// intrinsics
Eigen::Matrix3d intrinsics;
intrinsics<<f,0.,cu,0.,f,cv,0.,0.,1.;

// extrinsics set to zero
// REPLACE BY POSE FROM CAMERA TO MOTION CENTER
Eigen::Affine3d extrinsics = Eigen::Affine3d::Identity();

// camera storage class
momo::Camera cam(extrinsics, intrinsics);

// GET INPUT IMAGES I0 AND I1
// MATCH THEM WITH F.E. OPENCV AND STORE IN opencv_matches

// calculate viewing rays 
momo::MotionOptimizer::Matches input_matches;
for(const auto& el:opencv_matches){
    auto current_viewing_ray = match_to_viewing_ray(el[1], intrinsics);
    auto previous_viewing_ray = match_to_viewing_ray(el[0], intrinsics);
    input_matches.push_back(momo::MotionOptimizer::Match(previous_viewing_ray,current_viewing_ray));
}
momo::MotionOptimizer optimizer;

optimizer.AddData(input_matches, std::make_shared<momo::Camera>(cam), momo::commons::CostFunctionType::RayToEpipolarPlaneLinear)

// GET SCALE PRIOR FROM F.E. ODOMETRY AND STORE IN scale_prior

// calculate motion
Eigen::Affine3d current_motion; 
if (scale_prior > 0.01) {
        bool verbose = true;
        current_motion = optimizer.Solve(scale_prior, verbose);
}

}

Credits

Johannes Gräter

License

This software is under the LGPLv3 license