Commit 5e64ac0a authored by GilLevi's avatar GilLevi

added tests and renamed LATCH

parent f7c30998
......@@ -166,10 +166,10 @@ Note: the descriptor can be coupled with any keypoint extractor. The only demand
Note: a complete example can be found under /samples/cpp/tutorial_code/xfeatures2D/latch_match.cpp
*/
class CV_EXPORTS LATCHDescriptorExtractor : public DescriptorExtractor
class CV_EXPORTS LATCH : public DescriptorExtractor
{
public:
static Ptr<LATCHDescriptorExtractor> create(int bytes = 32, bool rotationInvariance = true, int half_ssd_size=3);
static Ptr<LATCH> create(int bytes = 32, bool rotationInvariance = true, int half_ssd_size=3);
};
......
#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);
}
......@@ -58,7 +58,7 @@ namespace cv
/*
* LATCH Descriptor
*/
class LATCHDescriptorExtractorImpl : public LATCHDescriptorExtractor
class LATCHDescriptorExtractorImpl : public LATCH
{
public:
enum { PATCH_SIZE = 48 };
......@@ -86,7 +86,7 @@ namespace cv
std::vector<int> sampling_points_ ;
};
Ptr<LATCHDescriptorExtractor> LATCHDescriptorExtractor::create(int bytes, bool rotationInvariance, int half_ssd_size)
Ptr<LATCH> LATCH::create(int bytes, bool rotationInvariance, int half_ssd_size)
{
return makePtr<LATCHDescriptorExtractorImpl>(bytes, rotationInvariance, half_ssd_size);
}
......@@ -488,10 +488,18 @@ namespace cv
fs << "descriptorSize" << bytes_;
}
void LATCHDescriptorExtractorImpl::compute(InputArray image,
void LATCHDescriptorExtractorImpl::compute(InputArray _image,
std::vector<KeyPoint>& keypoints,
OutputArray descriptors)
OutputArray _descriptors)
{
Mat image = _image.getMat();
if ( image.empty() )
return;
if ( keypoints.empty() )
return;
Mat grayImage;
GaussianBlur(image, grayImage, cv::Size(3, 3), 2, 2);
......@@ -502,9 +510,26 @@ namespace cv
//Remove keypoints very close to the border
KeyPointsFilter::runByImageBorder(keypoints, image.size(), PATCH_SIZE / 2 + half_ssd_size_);
bool _1d = false;
Mat descriptors;
_1d = _descriptors.kind() == _InputArray::STD_VECTOR && _descriptors.type() == CV_8U;
if( _1d )
{
_descriptors.create((int)keypoints.size()*bytes_, 1, CV_8U);
descriptors = _descriptors.getMat().reshape(1, (int)keypoints.size());
}
else
{
_descriptors.create((int)keypoints.size(), bytes_, CV_8U);
descriptors = _descriptors.getMat();
}
//_descriptors.create((int)keypoints.size(), bytes_, CV_8U);
// prepare descriptors as mat
//Mat descriptors = _descriptors.getMat();
descriptors.create((int)keypoints.size(), bytes_, CV_8U);
test_fn_(grayImage, keypoints, descriptors, sampling_points_, rotationInvariance_, half_ssd_size_);
}
......
......@@ -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
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment