Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap TwoViewMatchGeometricVerification::VerifyMatches #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ cmake_build

.vscode

.DS_Store

*.so

# Source for the following rules: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
Expand Down
2 changes: 1 addition & 1 deletion libraries/akaze/cimg/cmake-modules/FindOpenMP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ find_package_handle_standard_args(OpenMP DEFAULT_MSG
mark_as_advanced(
OpenMP_C_FLAGS
OpenMP_CXX_FLAGS
)
)
Binary file added src/.DS_Store
Binary file not shown.
26 changes: 19 additions & 7 deletions src/pytheia/matching/matching.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
#include "theia/matching/graph_match.h"
#include "theia/sfm/feature.h"
#include "theia/sfm/two_view_match_geometric_verification.h"
//#include "theia/matching/rocksdb_features_and_matches_database.h"
//#include "theia/matching/local_features_and_matches_database.h"
// #include "theia/matching/rocksdb_features_and_matches_database.h"
// #include "theia/matching/local_features_and_matches_database.h"
#include "theia/matching/create_feature_matcher.h"
#include "theia/matching/in_memory_features_and_matches_database.h"

Expand Down Expand Up @@ -208,6 +208,18 @@ void pytheia_matching_classes(py::module& m) {
.def_readwrite("descriptors",
&theia::KeypointsAndDescriptors::descriptors);

// Keypoint
py::class_<theia::Keypoint> keypoint(m, "Keypoint");
keypoint.def(py::init<>())
.def(py::init<float, float, theia::Keypoint::KeypointType>());

py::enum_<theia::Keypoint::KeypointType>(keypoint, "KeypointType")
.value("INVALID", theia::Keypoint::KeypointType::INVALID)
.value("OTHER", theia::Keypoint::KeypointType::OTHER)
.value("SIFT", theia::Keypoint::KeypointType::SIFT)
.value("AKAZE", theia::Keypoint::KeypointType::AKAZE)
.export_values();

// IndexedFeatureMatch
py::class_<theia::IndexedFeatureMatch>(m, "IndexedFeatureMatch")
.def(py::init<>())
Expand Down Expand Up @@ -260,11 +272,11 @@ void pytheia_matching_classes(py::module& m) {
//.def(py::init<theia::FeatureMatcherOptions,
//&theia::FeaturesAndMatchesDatabase>())
.def("AddImages",
(void (theia::FeatureMatcher::*)(const std::vector<std::string>&)) &
(void(theia::FeatureMatcher::*)(const std::vector<std::string>&)) &
theia::FeatureMatcher::AddImages,
py::return_value_policy::reference_internal)
.def("AddImage",
(void (theia::FeatureMatcher::*)(const std::string&)) &
(void(theia::FeatureMatcher::*)(const std::string&)) &
theia::FeatureMatcher::AddImage,
py::return_value_policy::reference_internal)
.def("MatchImages", &theia::FeatureMatcher::MatchImages)
Expand All @@ -279,7 +291,7 @@ void pytheia_matching_classes(py::module& m) {
theia::FeaturesAndMatchesDatabase*>())
// abstract class in the constructor
//.def(py::init<theia::FeatureMatcherOptions,
//theia::FeaturesAndMatchesDatabase>())
// theia::FeaturesAndMatchesDatabase>())

;

Expand All @@ -290,12 +302,12 @@ void pytheia_matching_classes(py::module& m) {
.def(py::init<theia::FeatureMatcherOptions,
theia::FeaturesAndMatchesDatabase*>())
.def("AddImages",
(void (theia::CascadeHashingFeatureMatcher::*)(
(void(theia::CascadeHashingFeatureMatcher::*)(
const std::vector<std::string>&)) &
theia::CascadeHashingFeatureMatcher::AddImages,
py::return_value_policy::reference_internal)
.def("AddImage",
(void (theia::CascadeHashingFeatureMatcher::*)(const std::string&)) &
(void(theia::CascadeHashingFeatureMatcher::*)(const std::string&)) &
theia::CascadeHashingFeatureMatcher::AddImage,
py::return_value_policy::reference_internal)

Expand Down
322 changes: 181 additions & 141 deletions src/pytheia/sfm/sfm.cc

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion src/theia/sfm/sfm_wrapper.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

#include "theia/sfm/sfm_wrapper.h"
#include "theia/matching/feature_correspondence.h"
#include "theia/sfm/reconstruction.h"
#include "theia/sfm/two_view_match_geometric_verification.h"
#include "theia/sfm/twoview_info.h"
#include "theia/sfm/view_graph/view_graph.h"
//#include "theia/image/image.h"
// #include "theia/image/image.h"
#include "theia/sfm/camera/camera.h"

namespace theia {
Expand All @@ -24,6 +26,23 @@ std::tuple<bool, TwoViewInfo, std::vector<int>> EstimateTwoViewInfoWrapper(
return std::make_tuple(success, twoview_info, inlier_indices);
}

std::tuple<bool, TwoViewInfo, std::vector<IndexedFeatureMatch>>
VerifyMatchesWrapper(const TwoViewMatchGeometricVerification::Options& options,
const CameraIntrinsicsPrior& intrinsics1,
const CameraIntrinsicsPrior& intrinsics2,
const KeypointsAndDescriptors& features1,
const KeypointsAndDescriptors& features2,
const std::vector<IndexedFeatureMatch>& matches) {
TwoViewMatchGeometricVerification geometric_verification(
options, intrinsics1, intrinsics2, features1, features2, matches);
TwoViewInfo twoview_info;
std::vector<FeatureCorrespondence> correspondences;
const bool success =
geometric_verification.VerifyMatches(&correspondences, &twoview_info);
return std::make_tuple(
success, twoview_info, geometric_verification.matches_);
}

std::tuple<bool, std::unordered_set<TrackId>>
SelectGoodTracksForBundleAdjustmentWrapper(
const Reconstruction& reconstruction,
Expand Down
12 changes: 10 additions & 2 deletions src/theia/sfm/sfm_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "theia/sfm/colorize_reconstruction.h"
#include "theia/sfm/estimate_twoview_info.h"
#include "theia/sfm/extract_maximally_parallel_rigid_subgraph.h"
#include "theia/sfm/two_view_match_geometric_verification.h"

#include "theia/sfm/filter_view_graph_cycles_by_rotation.h"
#include "theia/sfm/filter_view_pairs_from_orientation.h"
Expand All @@ -28,7 +29,15 @@ std::tuple<bool, TwoViewInfo, std::vector<int>> EstimateTwoViewInfoWrapper(
const CameraIntrinsicsPrior& intrinsics1,
const CameraIntrinsicsPrior& intrinsics2,
const std::vector<FeatureCorrespondence>& correspondences);


std::tuple<bool, TwoViewInfo, std::vector<IndexedFeatureMatch>>
VerifyMatchesWrapper(const TwoViewMatchGeometricVerification::Options& options,
const CameraIntrinsicsPrior& intrinsics1,
const CameraIntrinsicsPrior& intrinsics2,
const KeypointsAndDescriptors& features1,
const KeypointsAndDescriptors& features2,
const std::vector<IndexedFeatureMatch>& matches);

std::tuple<bool, std::unordered_set<TrackId>>
SelectGoodTracksForBundleAdjustmentWrapper(
const Reconstruction& reconstruction,
Expand All @@ -43,5 +52,4 @@ int SetOutlierTracksToUnestimatedWrapper(
const double min_triangulation_angle_degrees,
Reconstruction& reconstruction);


} // namespace theia
7 changes: 4 additions & 3 deletions src/theia/sfm/two_view_match_geometric_verification.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class TwoViewMatchGeometricVerification {
bool VerifyMatches(std::vector<FeatureCorrespondence>* verified_matches,
TwoViewInfo* twoview_info);

// We keep a local copy of the matches so that we may add and remove matches
// to it.
std::vector<IndexedFeatureMatch> matches_;

private:
// A helper method that creates a vector of FeatureCorrespondence from the
// matches_ vector of match indices.
Expand All @@ -130,9 +134,6 @@ class TwoViewMatchGeometricVerification {
const KeypointsAndDescriptors &features1_, features2_;

Camera camera1_, camera2_;
// We keep a local copy of the matches so that we may add and remove matches
// to it.
std::vector<IndexedFeatureMatch> matches_;

DISALLOW_COPY_AND_ASSIGN(TwoViewMatchGeometricVerification);
};
Expand Down
Loading