Skip to content

Commit 7b6fe5c

Browse files
committed
Merge pull request #231 from GilLevi/AddingLATCH
Adding the LATCH descriptor
2 parents 8fa8fa8 + 5e64ac0 commit 7b6fe5c

File tree

5 files changed

+1135
-0
lines changed

5 files changed

+1135
-0
lines changed

modules/xfeatures2d/include/opencv2/xfeatures2d.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,34 @@ class CV_EXPORTS_W LUCID : public Feature2D
145145
};
146146

147147

148+
/*
149+
* LATCH Descriptor
150+
*/
151+
152+
/** latch Class for computing the LATCH descriptor.
153+
If you find this code useful, please add a reference to the following paper in your work:
154+
Gil Levi and Tal Hassner, "LATCH: Learned Arrangements of Three Patch Codes", arXiv preprint arXiv:1501.03719, 15 Jan. 2015
155+
156+
LATCH is a binary descriptor based on learned comparisons of triplets of image patches.
157+
158+
* bytes is the size of the descriptor - can be 64, 32, 16, 8, 4, 2 or 1
159+
* rotationInvariance - whether or not the descriptor should compansate for orientation changes.
160+
* 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
161+
then the half_ssd_size should be (7-1)/2 = 3.
162+
163+
Note: the descriptor can be coupled with any keypoint extractor. The only demand is that if you use set rotationInvariance = True then
164+
you will have to use an extractor which estimates the patch orientation (in degrees). Examples for such extractors are ORB and SIFT.
165+
166+
Note: a complete example can be found under /samples/cpp/tutorial_code/xfeatures2D/latch_match.cpp
167+
168+
*/
169+
class CV_EXPORTS LATCH : public DescriptorExtractor
170+
{
171+
public:
172+
static Ptr<LATCH> create(int bytes = 32, bool rotationInvariance = true, int half_ssd_size=3);
173+
};
174+
175+
148176

149177
//! @}
150178

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "perf_precomp.hpp"
2+
3+
using namespace std;
4+
using namespace cv;
5+
using namespace cv::xfeatures2d;
6+
using namespace perf;
7+
using std::tr1::make_tuple;
8+
using std::tr1::get;
9+
10+
typedef perf::TestBaseWithParam<std::string> latch;
11+
12+
#define LATCH_IMAGES \
13+
"cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
14+
"stitching/a3.png"
15+
16+
PERF_TEST_P(latch, extract, testing::Values(LATCH_IMAGES))
17+
{
18+
string filename = getDataPath(GetParam());
19+
Mat frame = imread(filename, IMREAD_GRAYSCALE);
20+
ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
21+
22+
Mat mask;
23+
declare.in(frame).time(90);
24+
25+
Ptr<SURF> detector = SURF::create();
26+
vector<KeyPoint> points;
27+
detector->detect(frame, points, mask);
28+
29+
Ptr<LATCH> descriptor = LATCH::create();
30+
vector<uchar> descriptors;
31+
TEST_CYCLE() descriptor->compute(frame, points, descriptors);
32+
33+
SANITY_CHECK(descriptors, 1e-4);
34+
}

0 commit comments

Comments
 (0)