22#ifndef EOS_NONLINEAR_CAMERA_ESTIMATION_HPP
23#define EOS_NONLINEAR_CAMERA_ESTIMATION_HPP
25#include "eos/fitting/detail/nonlinear_camera_estimation_detail.hpp"
26#include "eos/fitting/RenderingParameters.hpp"
28#include "Eigen/Geometry"
29#include "unsupported/Eigen/NonLinearOptimization"
64 std::vector<Eigen::Vector4f> model_points,
int width,
67 assert(image_points.size() == model_points.size());
68 assert(image_points.size() >= 6);
70 const float aspect =
static_cast<float>(width) / height;
74 Eigen::VectorXd parameters;
75 parameters.setConstant(num_params, 0.0);
76 parameters[5] = 110.0;
77 detail::OrthographicParameterProjection cost_function(image_points, model_points, width, height);
80 Eigen::NumericalDiff<detail::OrthographicParameterProjection> cost_function_with_derivative(cost_function,
85 Eigen::LevenbergMarquardt<Eigen::NumericalDiff<detail::OrthographicParameterProjection>> lm(
86 cost_function_with_derivative);
87 const auto info = lm.minimize(parameters);
91 -1.0f * aspect *
static_cast<float>(parameters[5]), 1.0f * aspect *
static_cast<float>(parameters[5]),
92 -1.0f *
static_cast<float>(parameters[5]), 1.0f *
static_cast<float>(parameters[5])};
93 return RenderingParameters(CameraType::Orthographic, camera_frustum,
static_cast<float>(parameters[0]),
94 static_cast<float>(parameters[1]),
static_cast<float>(parameters[2]),
95 static_cast<float>(parameters[3]),
static_cast<float>(parameters[4]), width,
Represents a set of estimated model parameters (rotation, translation) and camera parameters (viewing...
Definition: RenderingParameters.hpp:102
RenderingParameters estimate_orthographic_camera(std::vector< Eigen::Vector2f > image_points, std::vector< Eigen::Vector4f > model_points, int width, int height)
This algorithm estimates the rotation angles and translation of the model, as well as the viewing fru...
Definition: nonlinear_camera_estimation.hpp:63
Namespace containing all of eos's 3D model fitting functionality.
A class representing a camera viewing frustum. At the moment only fully tested with orthographic came...
Definition: RenderingParameters.hpp:49