Skip to content

Commit

Permalink
Remove cross-dependencies between "feature" and "matching" modules
Browse files Browse the repository at this point in the history
Metric is now defined in the "feature" module.
  • Loading branch information
fabiencastan committed Jul 27, 2020
1 parent f8bfcae commit 8f3422d
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 37 deletions.
3 changes: 3 additions & 0 deletions src/aliceVision/feature/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ set(features_files_headers
Descriptor.hpp
feature.hpp
FeaturesPerView.hpp
Hamming.hpp
ImageDescriber.hpp
imageDescriberCommon.hpp
KeypointSet.hpp
metric.hpp
PointFeature.hpp
Regions.hpp
regionsFactory.hpp
Expand Down Expand Up @@ -88,3 +90,4 @@ endif()

# Unit tests
alicevision_add_test(features_test.cpp NAME "features" LINKS aliceVision_feature)
alicevision_add_test(metric_test.cpp NAME "descriptor_metric" LINKS aliceVision_feature)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

#include <aliceVision/matching/metric.hpp>
#include "metric.hpp"

#include <bitset>

Expand All @@ -29,7 +29,7 @@ typedef unsigned __int64 uint64_t;
// For maximal performance SSE4 must be enable for builtin popcount activation.

namespace aliceVision {
namespace matching {
namespace feature {

#undef PLATFORM_64_BIT
#undef PLATFORM_32_BIT
Expand Down Expand Up @@ -180,5 +180,5 @@ struct SquaredHamming
}
};

} // namespace matching
} // namespace feature
} // namespace aliceVision
6 changes: 3 additions & 3 deletions src/aliceVision/feature/Regions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <aliceVision/numeric/numeric.hpp>
#include <aliceVision/feature/PointFeature.hpp>
#include <aliceVision/feature/Descriptor.hpp>
#include <aliceVision/matching/metric.hpp>
#include <aliceVision/feature/metric.hpp>

#include <string>
#include <cstddef>
Expand Down Expand Up @@ -152,13 +152,13 @@ struct SquaredMetric;
template<typename T>
struct SquaredMetric<T, ERegionType::Scalar>
{
using Metric = matching::L2_Vectorized<T>;
using Metric = L2_Vectorized<T>;
};

template<typename T>
struct SquaredMetric<T, ERegionType::Binary>
{
using Metric = matching::SquaredHamming<T>;
using Metric = SquaredHamming<T>;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

#pragma once

#include "aliceVision/matching/Hamming.hpp"
#include "aliceVision/numeric/Accumulator.hpp"
#include "Hamming.hpp"

#include <aliceVision/numeric/Accumulator.hpp>
#include <aliceVision/config.hpp>

#if ALICEVISION_IS_DEFINED(ALICEVISION_HAVE_SSE)
Expand All @@ -18,8 +19,9 @@

#include <cstddef>


namespace aliceVision {
namespace matching {
namespace feature {

/// Squared Euclidean distance functor.
template<class T>
Expand Down Expand Up @@ -136,5 +138,5 @@ struct L2_Vectorized<float>

#endif // ALICEVISION_HAVE_SSE

} // namespace matching
} // namespace feature
} // namespace aliceVision
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

#include "aliceVision/matching/metric.hpp"
#include <aliceVision/feature/metric.hpp>

#include <iostream>
#include <string>

Expand All @@ -16,7 +17,7 @@

using namespace std;
using namespace aliceVision;
using namespace matching;
using namespace feature;

template<typename Metric>
typename Metric::ResultType DistanceT()
Expand Down
13 changes: 8 additions & 5 deletions src/aliceVision/matching/ArrayMatcher_bruteForce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@

#pragma once

#include "aliceVision/numeric/numeric.hpp"
#include "aliceVision/matching/ArrayMatcher.hpp"
#include "aliceVision/matching/metric.hpp"
#include "aliceVision/stl/indexedSort.hpp"
#include <aliceVision/numeric/numeric.hpp>
#include <aliceVision/matching/ArrayMatcher.hpp>
#include <aliceVision/feature/metric.hpp>
#include <aliceVision/stl/indexedSort.hpp>

#include <aliceVision/config.hpp>

#include <memory>
#include <iostream>


namespace aliceVision {
namespace matching {

// By default compute square(L2 distance).
template < typename Scalar = float, typename Metric = L2_Simple<Scalar> >
template < typename Scalar = float, typename Metric = feature::L2_Simple<Scalar> >
class ArrayMatcher_bruteForce : public ArrayMatcher<Scalar, Metric>
{
public:
Expand Down
9 changes: 5 additions & 4 deletions src/aliceVision/matching/ArrayMatcher_cascadeHashing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

#pragma once

#include "aliceVision/matching/ArrayMatcher.hpp"
#include "aliceVision/matching/CascadeHasher.hpp"
#include "aliceVision/matching/IndMatch.hpp"
#include <aliceVision/feature/metric.hpp>
#include <aliceVision/matching/ArrayMatcher.hpp>
#include <aliceVision/matching/CascadeHasher.hpp>
#include <aliceVision/matching/IndMatch.hpp>

#include <aliceVision/system/Logger.hpp>

Expand All @@ -32,7 +33,7 @@ namespace matching {
// Implementation of descriptor matching using the cascade hashing method of [1].
// If you use this matcher, please cite the paper.
// template Metric parameter is ignored (by default compute square(L2 distance)).
template < typename Scalar = float, typename Metric = L2_Simple<Scalar> >
template < typename Scalar = float, typename Metric = feature::L2_Simple<Scalar> >
class ArrayMatcher_cascadeHashing : public ArrayMatcher<Scalar, Metric>
{
public:
Expand Down
3 changes: 0 additions & 3 deletions src/aliceVision/matching/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ set(matching_files_headers
guidedMatching.hpp
io.hpp
matcherType.hpp
metric.hpp
Hamming.hpp
CascadeHasher.hpp
RegionsMatcher.hpp
pairwiseAdjacencyDisplay.hpp
Expand Down Expand Up @@ -49,6 +47,5 @@ alicevision_add_library(aliceVision_matching
alicevision_add_test(matching_test.cpp NAME "matching" LINKS aliceVision_matching)
alicevision_add_test(filters_test.cpp NAME "matching_filters" LINKS aliceVision_matching)
alicevision_add_test(indMatch_test.cpp NAME "matching_indMatch" LINKS aliceVision_matching)
alicevision_add_test(metric_test.cpp NAME "matching_metric" LINKS aliceVision_matching)

add_subdirectory(kvld)
13 changes: 7 additions & 6 deletions src/aliceVision/matching/CascadeHasher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

#pragma once

#include "aliceVision/numeric/numeric.hpp"
#include "aliceVision/matching/metric.hpp"
#include "aliceVision/matching/IndMatch.hpp"
#include "aliceVision/stl/DynamicBitset.hpp"
#include <aliceVision/numeric/numeric.hpp>
#include <aliceVision/feature/metric.hpp>
#include <aliceVision/matching/IndMatch.hpp>
#include <aliceVision/stl/DynamicBitset.hpp>

#include <iostream>
#include <random>
#include <cmath>
Expand Down Expand Up @@ -229,7 +230,7 @@ class CascadeHasher {
const int NN = 2
) const
{
typedef L2_Vectorized<typename MatrixT::Scalar> MetricT;
typedef feature::L2_Vectorized<typename MatrixT::Scalar> MetricT;
MetricT metric;

static const int kNumTopCandidates = 10;
Expand All @@ -254,7 +255,7 @@ class CascadeHasher {
// feature for matching (i.e., prevents duplicates).
std::vector<bool> used_descriptor(hashed_descriptions2.hashed_desc.size());

typedef matching::Hamming<stl::dynamic_bitset::BlockType> HammingMetricType;
typedef feature::Hamming<stl::dynamic_bitset::BlockType> HammingMetricType;
static const HammingMetricType metricH = {};
for (int i = 0; i < hashed_descriptions1.hashed_desc.size(); ++i)
{
Expand Down
12 changes: 6 additions & 6 deletions src/aliceVision/matching/RegionsMatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ std::unique_ptr<IRegionsMatcher> createRegionsMatcher(const feature::Regions & r
{
case BRUTE_FORCE_L2:
{
typedef L2_Vectorized<unsigned char> MetricT;
typedef feature::L2_Vectorized<unsigned char> MetricT;
typedef ArrayMatcher_bruteForce<unsigned char, MetricT> MatcherT;
out.reset(new matching::RegionsMatcher<MatcherT>(regions, true));
}
Expand All @@ -89,7 +89,7 @@ std::unique_ptr<IRegionsMatcher> createRegionsMatcher(const feature::Regions & r
break;
case CASCADE_HASHING_L2:
{
typedef L2_Vectorized<unsigned char> MetricT;
typedef feature::L2_Vectorized<unsigned char> MetricT;
typedef ArrayMatcher_cascadeHashing<unsigned char, MetricT> MatcherT;
out.reset(new matching::RegionsMatcher<MatcherT>(regions, true));
}
Expand All @@ -105,7 +105,7 @@ std::unique_ptr<IRegionsMatcher> createRegionsMatcher(const feature::Regions & r
{
case BRUTE_FORCE_L2:
{
typedef L2_Vectorized<float> MetricT;
typedef feature::L2_Vectorized<float> MetricT;
typedef ArrayMatcher_bruteForce<float, MetricT> MatcherT;
out.reset(new matching::RegionsMatcher<MatcherT>(regions, true));
}
Expand All @@ -118,7 +118,7 @@ std::unique_ptr<IRegionsMatcher> createRegionsMatcher(const feature::Regions & r
break;
case CASCADE_HASHING_L2:
{
typedef L2_Vectorized<float> MetricT;
typedef feature::L2_Vectorized<float> MetricT;
typedef ArrayMatcher_cascadeHashing<float, MetricT> MatcherT;
out.reset(new matching::RegionsMatcher<MatcherT>(regions, true));
}
Expand All @@ -134,7 +134,7 @@ std::unique_ptr<IRegionsMatcher> createRegionsMatcher(const feature::Regions & r
{
case BRUTE_FORCE_L2:
{
typedef L2_Vectorized<double> MetricT;
typedef feature::L2_Vectorized<double> MetricT;
typedef ArrayMatcher_bruteForce<double, MetricT> MatcherT;
out.reset(new matching::RegionsMatcher<MatcherT>(regions, true));
}
Expand All @@ -161,7 +161,7 @@ std::unique_ptr<IRegionsMatcher> createRegionsMatcher(const feature::Regions & r
{
case BRUTE_FORCE_HAMMING:
{
typedef Hamming<unsigned char> Metric;
typedef feature::Hamming<unsigned char> Metric;
typedef ArrayMatcher_bruteForce<unsigned char, Metric> MatcherT;
out.reset(new matching::RegionsMatcher<MatcherT>(regions, false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// You can obtain one at https://mozilla.org/MPL/2.0/.

#include "StructureEstimationFromKnownPoses.hpp"
#include <aliceVision/feature/metric.hpp>
#include <aliceVision/matching/IndMatch.hpp>
#include <aliceVision/matching/metric.hpp>
#include <aliceVision/matching/guidedMatching.hpp>
#include <aliceVision/multiview/relativePose/FundamentalError.hpp>
#include <aliceVision/multiview/triangulation/Triangulation.hpp>
Expand Down

0 comments on commit 8f3422d

Please sign in to comment.