Merge pull request #231 from GilLevi/AddingLATCH

Adding the LATCH descriptor
pull/237/head
Vadim Pisarevsky 10 years ago
commit 7b6fe5cdf9
  1. 28
      modules/xfeatures2d/include/opencv2/xfeatures2d.hpp
  2. 34
      modules/xfeatures2d/perf/perf_latch.cpp
  3. 1056
      modules/xfeatures2d/src/latch.cpp
  4. 7
      modules/xfeatures2d/test/test_features2d.cpp
  5. 10
      modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp

@ -145,6 +145,34 @@ public:
};
/*
* LATCH Descriptor
*/
/** latch Class for computing the LATCH descriptor.
If you find this code useful, please add a reference to the following paper in your work:
Gil Levi and Tal Hassner, "LATCH: Learned Arrangements of Three Patch Codes", arXiv preprint arXiv:1501.03719, 15 Jan. 2015
LATCH is a binary descriptor based on learned comparisons of triplets of image patches.
* bytes is the size of the descriptor - can be 64, 32, 16, 8, 4, 2 or 1
* rotationInvariance - whether or not the descriptor should compansate for orientation changes.
* half_ssd_size - the size of half of the mini-patches size. For example, if we would like to compare triplets of patches of size 7x7x
then the half_ssd_size should be (7-1)/2 = 3.
Note: the descriptor can be coupled with any keypoint extractor. The only demand is that if you use set rotationInvariance = True then
you will have to use an extractor which estimates the patch orientation (in degrees). Examples for such extractors are ORB and SIFT.
Note: a complete example can be found under /samples/cpp/tutorial_code/xfeatures2D/latch_match.cpp
*/
class CV_EXPORTS LATCH : public DescriptorExtractor
{
public:
static Ptr<LATCH> create(int bytes = 32, bool rotationInvariance = true, int half_ssd_size=3);
};
//! @}

@ -0,0 +1,34 @@
#include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace cv::xfeatures2d;
using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
typedef perf::TestBaseWithParam<std::string> latch;
#define LATCH_IMAGES \
"cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
"stitching/a3.png"
PERF_TEST_P(latch, extract, testing::Values(LATCH_IMAGES))
{
string filename = getDataPath(GetParam());
Mat frame = imread(filename, IMREAD_GRAYSCALE);
ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
Mat mask;
declare.in(frame).time(90);
Ptr<SURF> detector = SURF::create();
vector<KeyPoint> points;
detector->detect(frame, points, mask);
Ptr<LATCH> descriptor = LATCH::create();
vector<uchar> descriptors;
TEST_CYCLE() descriptor->compute(frame, points, descriptors);
SANITY_CHECK(descriptors, 1e-4);
}

File diff suppressed because it is too large Load Diff

@ -1032,6 +1032,13 @@ TEST( Features2d_DescriptorExtractor_LUCID, regression )
test.safe_run();
}
TEST( Features2d_DescriptorExtractor_LATCH, regression )
{
CV_DescriptorExtractorTest<Hamming> test( "descriptor-latch", 1,
LATCH::create() );
test.safe_run();
}
/*#if CV_SSE2

@ -651,6 +651,16 @@ TEST(Features2d_RotationInvariance_Descriptor_SIFT, regression)
test.safe_run();
}
TEST(Features2d_RotationInvariance_Descriptor_LATCH, regression)
{
DescriptorRotationInvarianceTest test(SIFT::create(),
LATCH::create(),
NORM_HAMMING,
0.9999f);
test.safe_run();
}
/*
* Detector's scale invariance check
*/

Loading…
Cancel
Save