Skip to content

Commit

Permalink
MAINT: add global translation minimal solver.
Browse files Browse the repository at this point in the history
  • Loading branch information
oddkiva committed Apr 30, 2024
1 parent cb4118b commit 4f51ab2
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ========================================================================== //
// This file is part of Sara, a basic set of libraries in C++ for computer
// vision.
//
// Copyright (C) 2024-present David Ok <[email protected]>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================== //

#pragma once

#include <Eigen/Dense>
#include <Eigen/Eigen>


namespace DO::Sara {

//! @brief Two-point solver that solves the absolute translation given a known
//! absolute rotaton.
//!
//! Turns out to be very basic...
template <typename T>
struct AbsoluteTranslationSolver
{
static constexpr auto num_points = 2;
static constexpr auto num_models = 1;

using model_type = Eigen::Vector3<T>;

//! @brief Inputs are rotated world scene points and the backprojected rays.
auto operator()(const Eigen::Matrix<T, 3, 2>& Rx,
const Eigen::Matrix<T, 3, 2>& y) const -> model_type
{
const auto x0 = Rx.col(0);
const auto x1 = Rx.col(1);
const auto y0 = y.col(0);
const auto y1 = y.col(1);

static const auto I3 = Eigen::Matrix3<T>::Identity();
static const auto O3 = Eigen::Vector3<T>::Zero();

auto A = Eigen::Matrix<T, 6, 5>{};
A.template topRows<3>() << I3, y0, O3;
A.template bottomRows<3>() << I3, O3, y1;

auto b = Eigen::Vector<T, 6>{};
b << x0, x1;

return A.template colPivHouseholderQr().solve(b);
}
};

} // namespace DO::Sara
#pragma once
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
// ========================================================================== //
// This file is part of Sara, a basic set of libraries in C++ for computer
// vision.
//
// Copyright (C) 2024-present David Ok <[email protected]>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================== //

#include <DO/Sara/MultiViewGeometry/MinimalSolvers/SevenPointAlgorithm.hpp>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
// ========================================================================== //
// This file is part of Sara, a basic set of libraries in C++ for computer
// vision.
//
// Copyright (C) 2024-present David Ok <[email protected]>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================== //

#pragma once

#include <DO/Sara/Defines.hpp>
Expand Down

0 comments on commit 4f51ab2

Please sign in to comment.