Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.8)
project(GraphCutRANSAC LANGUAGES CXX)

# indicate if OPENMP should be enabled
option(CREATE_SAMPLE_PROJECT "Create the Sample Project" ON)
option(CREATE_SAMPLE_PROJECT "Create the Sample Project" OFF)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -56,11 +56,10 @@ file(GLOB_RECURSE SRCS_GCRANSAC
"${SOURCE_DIR}/include/*.cpp"
)


# Generate python module
add_subdirectory(lib/pybind11)

pybind11_add_module(pygcransac ${SOURCE_DIR}/src/bindings.cpp ${SOURCE_DIR}/src/gcransac_python.cpp ${HDRS_GCRANSAC} ${SRCS_GCRANSAC} )
pybind11_add_module(pygcransac ${SOURCE_DIR}/src/bindings.cpp ${HDRS_GCRANSAC} ${SRCS_GCRANSAC})
target_link_libraries(pygcransac PRIVATE ${OpenCV_LIBS} Eigen3::Eigen)
install(TARGETS pygcransac DESTINATION .)

Expand Down
1 change: 1 addition & 0 deletions src/pygcransac/include/estimators/estimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#pragma once

#include <vector>
#include <opencv2/core/core.hpp>
#include "GCoptimization.h"

namespace gcransac
Expand Down
10 changes: 5 additions & 5 deletions src/pygcransac/include/estimators/solver_acp1p_cayley.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ namespace gcransac
const double *weights_ = nullptr) const; // The weight for each point

protected:
void cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const;
int re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change = true) const;
OLGA_INLINE void cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const;
OLGA_INLINE int re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change = true) const;
inline void refine_3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, int n_sols) const;
};

Expand Down Expand Up @@ -159,7 +159,7 @@ namespace gcransac
return models_.size();
}

void ACP1PCayleySolver::cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const
OLGA_INLINE void ACP1PCayleySolver::cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const
{
const double x = r(0);
const double y = r(1);
Expand Down Expand Up @@ -225,7 +225,7 @@ namespace gcransac
* Order of coefficients is: x^2, xy, xz, y^2, yz, z^2, x, y, z, 1.0;
*
*/
int ACP1PCayleySolver::re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change) const {
OLGA_INLINE int ACP1PCayleySolver::re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change) const {

Eigen::Matrix<double, 3, 3> Ax, Ay, Az;
Ax << coeffs.col(3), coeffs.col(5), coeffs.col(4); // y^2, z^2, yz
Expand Down Expand Up @@ -391,4 +391,4 @@ namespace gcransac
}
}
}
}
}
14 changes: 7 additions & 7 deletions src/pygcransac/include/estimators/solver_dls_pnp.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace gcransac
const double *weights_ = nullptr) const; // The weight for each point

protected:
void createMacaulayMatrix(
OLGA_INLINE void createMacaulayMatrix(
const double a[20],
const double b[20],
const double c[20],
Expand All @@ -94,11 +94,11 @@ namespace gcransac
// Transforms a 3 - vector in a 3x9 matrix such that :
// R * v = leftMultiplyMatrix(v) * vec(R)
// Where R is a rotation matrix and vec(R) converts R to a 9x1 vector.
Eigen::Matrix<double, 3, 9> leftMultiplyMatrix(const Eigen::Vector3d& v) const;
OLGA_INLINE Eigen::Matrix<double, 3, 9> leftMultiplyMatrix(const Eigen::Vector3d& v) const;

// Extracts the coefficients of the Jacobians of the LS cost function (which is
// parameterized by the 3 rotation coefficients s1, s2, s3).
void extractJacobianCoefficients(
OLGA_INLINE void extractJacobianCoefficients(
const Eigen::Matrix<double, 9, 9>& D,
double f1_coeff[20],
double f2_coeff[20],
Expand Down Expand Up @@ -268,7 +268,7 @@ namespace gcransac
// Transforms a 3 - vector in a 3x9 matrix such that :
// R * v = leftMultiplyMatrix(v) * vec(R)
// Where R is a rotation matrix and vec(R) converts R to a 9x1 vector.
Eigen::Matrix<double, 3, 9> DLSPnP::leftMultiplyMatrix(const Eigen::Vector3d& v) const
OLGA_INLINE Eigen::Matrix<double, 3, 9> DLSPnP::leftMultiplyMatrix(const Eigen::Vector3d& v) const
{
Eigen::Matrix<double, 3, 9> left_mult_mat = Eigen::Matrix<double, 3, 9>::Zero();
left_mult_mat.block<1, 3>(0, 0) = v.transpose();
Expand All @@ -279,7 +279,7 @@ namespace gcransac

// Extracts the coefficients of the Jacobians of the LS cost function (which is
// parameterized by the 3 rotation coefficients s1, s2, s3).
void DLSPnP::extractJacobianCoefficients(
OLGA_INLINE void DLSPnP::extractJacobianCoefficients(
const Eigen::Matrix<double, 9, 9>& D,
double f1_coeff[20],
double f2_coeff[20],
Expand Down Expand Up @@ -557,7 +557,7 @@ namespace gcransac
2 * D(8, 2) - 2 * D(8, 6)); // s1^3
}

void DLSPnP::createMacaulayMatrix(const double a[20],
OLGA_INLINE void DLSPnP::createMacaulayMatrix(const double a[20],
const double b[20],
const double c[20],
const double u[4],
Expand Down Expand Up @@ -924,4 +924,4 @@ namespace gcransac

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace gcransac
Eigen::Matrix3d gravity_source;
Eigen::Matrix3d gravity_destination;

Eigen::MatrixXcd solver_3pt_caliess(const Eigen::VectorXd &data_) const;
OLGA_INLINE Eigen::MatrixXcd solver_3pt_caliess(const Eigen::VectorXd &data_) const;
};

OLGA_INLINE bool EssentialMatrixThreePointsGravity::estimateModel(
Expand Down Expand Up @@ -185,7 +185,7 @@ namespace gcransac
return models_.size() > 0;
}

Eigen::MatrixXcd EssentialMatrixThreePointsGravity::solver_3pt_caliess(const Eigen::VectorXd &data_) const
OLGA_INLINE Eigen::MatrixXcd EssentialMatrixThreePointsGravity::solver_3pt_caliess(const Eigen::VectorXd &data_) const
{
using namespace Eigen;

Expand Down
22 changes: 11 additions & 11 deletions src/pygcransac/include/estimators/solver_siftp1p.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace gcransac
protected:
Eigen::Matrix3d Rxz;

void solver(
OLGA_INLINE void solver(
const Eigen::Matrix3d &R_ref,
const Eigen::Vector3d &t_ref,
const double s1, // sin of angle in first view
Expand All @@ -108,11 +108,11 @@ namespace gcransac
std::vector<Eigen::Vector3d> &tsolns
) const;

int re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change = true) const;
void refine_3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, int n_sols) const ;
OLGA_INLINE int re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change = true) const;
OLGA_INLINE void refine_3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, int n_sols) const ;

void cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const;
Eigen::MatrixXd build_linear_constraints(
OLGA_INLINE void cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const;
OLGA_INLINE Eigen::MatrixXd build_linear_constraints(
const Eigen::Matrix3d &R_ref,
const Eigen::Vector3d &t_ref,
const double s1, //sin of angle in first view
Expand Down Expand Up @@ -206,7 +206,7 @@ namespace gcransac
return models_.size();
}

Eigen::MatrixXd SIFTP1PSolver::build_linear_constraints(
OLGA_INLINE Eigen::MatrixXd SIFTP1PSolver::build_linear_constraints(
const Eigen::Matrix3d &R_ref,
const Eigen::Vector3d &t_ref,
const double s1, //sin of angle in first view
Expand All @@ -229,7 +229,7 @@ namespace gcransac
return M;
}

void SIFTP1PSolver::cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const
OLGA_INLINE void SIFTP1PSolver::cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const
{
const double x = r(0);
const double y = r(1);
Expand All @@ -253,7 +253,7 @@ namespace gcransac
2*(xz-yw), 2*(xw+yz), ww-xx-yy+zz;
}

void SIFTP1PSolver::solver(
OLGA_INLINE void SIFTP1PSolver::solver(
const Eigen::Matrix3d &R_ref,
const Eigen::Vector3d &t_ref,
const double s1, // sin of angle in first view
Expand Down Expand Up @@ -304,7 +304,7 @@ namespace gcransac
}
}

void SIFTP1PSolver::refine_3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, int n_sols) const
OLGA_INLINE void SIFTP1PSolver::refine_3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, int n_sols) const
{
Eigen::Matrix3d J;
Eigen::Vector3d r;
Expand Down Expand Up @@ -346,7 +346,7 @@ namespace gcransac
* Order of coefficients is: x^2, xy, xz, y^2, yz, z^2, x, y, z, 1.0;
*
*/
int SIFTP1PSolver::re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change) const
OLGA_INLINE int SIFTP1PSolver::re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change) const
{

Eigen::Matrix<double, 3, 3> Ax, Ay, Az;
Expand Down Expand Up @@ -513,4 +513,4 @@ namespace gcransac
}
}
}
}
}
22 changes: 11 additions & 11 deletions src/pygcransac/include/estimators/solver_siftp2p.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace gcransac
const double *weights_ = nullptr) const; // The weight for each point

protected:
void solver(
OLGA_INLINE void solver(
const double s1[], // sin of angle in first view
const double c1[], // cos of angle in first view
const double s2[], // sin of angle in second view
Expand Down Expand Up @@ -119,11 +119,11 @@ namespace gcransac
std::vector<Eigen::Matrix3d> &Rsolns, std::vector<Eigen::Vector3d> &tsolns*/
) const;

int re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change = true) const;
void refine_3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, int n_sols) const ;
OLGA_INLINE int re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change = true) const;
OLGA_INLINE void refine_3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, int n_sols) const ;

void cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const;
Eigen::MatrixXd build_constraints(
OLGA_INLINE void cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const;
OLGA_INLINE Eigen::MatrixXd build_constraints(
const Eigen::Matrix3d &R_ref,
const Eigen::Vector3d &t_ref,
const double s1, //sin of angle in first view
Expand Down Expand Up @@ -210,7 +210,7 @@ namespace gcransac
return models_.size();
}

Eigen::MatrixXd SIFTP2PQuerySolver::build_constraints(
OLGA_INLINE Eigen::MatrixXd SIFTP2PQuerySolver::build_constraints(
const Eigen::Matrix3d &R_ref,
const Eigen::Vector3d &t_ref,
const double s1, //sin of angle in first view
Expand All @@ -229,7 +229,7 @@ namespace gcransac
return M;
}

void SIFTP2PQuerySolver::cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const
OLGA_INLINE void SIFTP2PQuerySolver::cayley(const Eigen::Vector3d &r, Eigen::Matrix3d &R, double &s ) const
{
const double x = r(0);
const double y = r(1);
Expand All @@ -253,7 +253,7 @@ namespace gcransac
2*(xz-yw), 2*(xw+yz), ww-xx-yy+zz;
}

void SIFTP2PQuerySolver::solver(
OLGA_INLINE void SIFTP2PQuerySolver::solver(
const double s1[], // sin of angle in first view
const double c1[], // cos of angle in first view
const double s2[], // sin of angle in second view
Expand Down Expand Up @@ -296,7 +296,7 @@ namespace gcransac
}
}

void SIFTP2PQuerySolver::refine_3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, int n_sols) const
OLGA_INLINE void SIFTP2PQuerySolver::refine_3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, int n_sols) const
{
Eigen::Matrix3d J;
Eigen::Vector3d r;
Expand Down Expand Up @@ -338,7 +338,7 @@ namespace gcransac
* Order of coefficients is: x^2, xy, xz, y^2, yz, z^2, x, y, z, 1.0;
*
*/
int SIFTP2PQuerySolver::re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change) const
OLGA_INLINE int SIFTP2PQuerySolver::re3q3(const Eigen::Matrix<double, 3, 10> &coeffs, Eigen::Matrix<double, 3, 8> *solutions, bool try_random_var_change) const
{

Eigen::Matrix<double, 3, 3> Ax, Ay, Az;
Expand Down Expand Up @@ -505,4 +505,4 @@ namespace gcransac
}
}
}
}
}
Loading