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

Fix DSPSIFT color pick #36

Merged
merged 2 commits into from
Jul 24, 2024
Merged
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: 1 addition & 1 deletion opensfm/src/features/dspsift.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace features {

py::tuple dspsift(foundation::pyarray_f image, float peak_threshold,
float edge_threshold, int target_num_features,
bool feature_root, bool domain_size_pooling, bool estimate_affine_shape);
bool feature_root, bool domain_size_pooling, bool estimate_affine_shape, int border_size);

}
3 changes: 2 additions & 1 deletion opensfm/src/features/python/pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ PYBIND11_MODULE(pyfeatures, m) {
py::arg("target_num_features") = 0,
py::arg("feature_root") = true,
py::arg("domain_size_pooling") = true,
py::arg("estimate_affine_shape") = true);
py::arg("estimate_affine_shape") = true,
py::arg("border_size") = 5);

m.def("match_using_words", features::match_using_words);
m.def("compute_vlad_descriptor", features::compute_vlad_descriptor,
Expand Down
16 changes: 15 additions & 1 deletion opensfm/src/features/src/dspsift.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Copyright (c) 2023, ETH Zurich and UNC Chapel Hill.
#include <iostream>
#include <vector>
#include <memory>
#include <algorithm>
#include <Eigen/Core>

extern "C" {
Expand Down Expand Up @@ -47,11 +48,18 @@ namespace features {

py::tuple dspsift(foundation::pyarray_f image, float peak_threshold,
float edge_threshold, int target_num_features,
bool feature_root, bool domain_size_pooling, bool estimate_affine_shape) {
bool feature_root, bool domain_size_pooling, bool estimate_affine_shape, int border_size) {
if (!image.size()) {
return py::none();
}

int width = image.shape(1);
int height = image.shape(0);

if (border_size*2 >= width || border_size*2 >= height) {
return py::none();
}

FeatureDescriptors descriptors;
FeatureKeypoints keypoints;
int keypoints_count = 0;
Expand Down Expand Up @@ -103,7 +111,13 @@ py::tuple dspsift(foundation::pyarray_f image, float peak_threshold,
}

VlCovDetFeature* features = vl_covdet_get_features(covdet.get());

VlCovDetFeature* middle = std::partition(features, features + num_features, [border_size, width, height](const VlCovDetFeature& feature) {
return feature.frame.x >= border_size && feature.frame.x < width - border_size &&
feature.frame.y >= border_size && feature.frame.y < height - border_size;
});

num_features = middle - features;

// Sort features according to detected octave and scale.
std::sort(
Expand Down
Loading