Skip to content

Commit

Permalink
Merge pull request #36 from originlake/fix
Browse files Browse the repository at this point in the history
Fix DSPSIFT color pick
  • Loading branch information
pierotofy authored Jul 24, 2024
2 parents 24993f4 + 1a5f417 commit 18a39c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
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

0 comments on commit 18a39c5

Please sign in to comment.