Commit 8ca9b9c5 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #486 from cbalint13:vgg

parents ac62d70f 593e78c5
......@@ -8,3 +8,5 @@
Thumbs.db
tags
tegra/
*.i
.download*
set(the_description "Contributed/Experimental Algorithms for Salient 2D Features Detection")
ocv_define_module(xfeatures2d opencv_core opencv_imgproc opencv_features2d opencv_calib3d opencv_shape opencv_highgui opencv_videoio opencv_ml
OPTIONAL opencv_cudaarithm WRAP python java)
include(cmake/download_vgg.cmake)
\ No newline at end of file
set(OPENCV_3RDPARTY_COMMIT "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d")
set(FILE_HASH_VGG_48 "e8d0dcd54d1bcfdc29203d011a797179")
set(FILE_HASH_VGG_64 "7126a5d9a8884ebca5aea5d63d677225")
set(FILE_HASH_VGG_80 "7cd47228edec52b6d82f46511af325c5")
set(FILE_HASH_VGG_120 "151805e03568c9f490a5e3a872777b75")
set(VGG_DOWNLOAD_URL ${OPENCV_CONTRIB_VGG_URL};$ENV{OPENCV_CONTRIB_VGG_URL};https://raw.githubusercontent.com/Itseez/opencv_3rdparty/${OPENCV_3RDPARTY_COMMIT}/)
function(vgg_download file id)
message(STATUS "Check contents of ${file} ...")
ocv_download(PACKAGE ${file}
HASH ${FILE_HASH_${id}}
URL ${VGG_DOWNLOAD_URL}
DESTINATION_DIR ${CMAKE_CURRENT_LIST_DIR}/../src
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}/.download)
endfunction()
vgg_download(vgg_generated_48.i VGG_48)
vgg_download(vgg_generated_64.i VGG_64)
vgg_download(vgg_generated_80.i VGG_80)
vgg_download(vgg_generated_120.i VGG_120)
......@@ -71,3 +71,10 @@
booktitle={Asian Conference on Computer Vision -- ACCV 2014},
year={2014}
}
@article{Simonyan14,
author = "Simonyan, K. and Vedaldi, A. and Zisserman, A.",
title = "Learning Local Feature Descriptors Using Convex Optimisation",
journal = "IEEE Transactions on Pattern Analysis and Machine Intelligence",
year = "2014"
}
......@@ -168,7 +168,7 @@ Note: a complete example can be found under /samples/cpp/tutorial_code/xfeatures
class CV_EXPORTS_W LATCH : public Feature2D
{
public:
CV_WRAP static Ptr<LATCH> create(int bytes = 32, bool rotationInvariance = true, int half_ssd_size=3);
CV_WRAP static Ptr<LATCH> create(int bytes = 32, bool rotationInvariance = true, int half_ssd_size=3);
};
/** @brief Class implementing DAISY descriptor, described in @cite Tola10
......@@ -280,6 +280,44 @@ public:
float m_scale_factor = 1.25f, int m_n_scales = -1, bool m_compute_orientation = false);
};
/** @brief Class implementing VGG (Oxford Visual Geometry Group) descriptor trained end to end
using "Descriptor Learning Using Convex Optimisation" (DLCO) aparatus described in @cite Simonyan14.
@param desc type of descriptor to use, VGG::VGG_120 is default (120 dimensions float)
Available types are VGG::VGG_120, VGG::VGG_80, VGG::VGG_64, VGG::VGG_48
@param isigma gaussian kernel value for image blur (default is 1.4f)
@param img_normalize use image sample intensity normalization (enabled by default)
@param use_orientation sample patterns using keypoints orientation, enabled by default
@param scale_factor adjust the sampling window of detected keypoints to 64.0f (VGG sampling window)
6.25f is default and fits for KAZE, SURF detected keypoints window ratio
6.75f should be the scale for SIFT detected keypoints window ratio
5.00f should be the scale for AKAZE, MSD, AGAST, FAST, BRISK keypoints window ratio
0.75f should be the scale for ORB keypoints ratio
@param dsc_normalize clamp descriptors to 255 and convert to uchar CV_8UC1 (disabled by default)
*/
class CV_EXPORTS_W VGG : public Feature2D
{
public:
CV_WRAP enum
{
VGG_120 = 100, VGG_80 = 101, VGG_64 = 102, VGG_48 = 103,
};
CV_WRAP static Ptr<VGG> create( int desc = VGG::VGG_120, float isigma = 1.4f,
bool img_normalize = true, bool use_scale_orientation = true,
float scale_factor = 6.25f, bool dsc_normalize = false );
/**
* @param image image to extract descriptors
* @param keypoints of interest within image
* @param descriptors resulted descriptors array
*/
CV_WRAP virtual void compute( InputArray image, std::vector<KeyPoint>& keypoints, OutputArray descriptors ) = 0;
};
//! @}
}
......
#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> vgg;
#define VGG_IMAGES \
"cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
"stitching/a3.png"
PERF_TEST_P(vgg, extract, testing::Values(VGG_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<KAZE> detector = KAZE::create();
vector<KeyPoint> points;
detector->detect(frame, points, mask);
Ptr<VGG> descriptor = VGG::create();
Mat_<float> descriptors;
// compute keypoints descriptor
TEST_CYCLE() descriptor->compute(frame, points, descriptors);
SANITY_CHECK_NOTHING();
}
This diff is collapsed.
......@@ -1050,6 +1050,12 @@ TEST( Features2d_DescriptorExtractor_LATCH, regression )
test.safe_run();
}
TEST( Features2d_DescriptorExtractor_VGG, regression )
{
CV_DescriptorExtractorTest<L2<float> > test( "descriptor-vgg", 0.03f,
VGG::create() );
test.safe_run();
}
/*#if CV_SSE2
......
......@@ -671,6 +671,42 @@ TEST(DISABLED_Features2d_RotationInvariance_Descriptor_DAISY, regression)
test.safe_run();
}
TEST(Features2d_RotationInvariance_Descriptor_VGG120, regression)
{
DescriptorRotationInvarianceTest test(KAZE::create(),
VGG::create(VGG::VGG_120, 1.4f, true, true, 48.0f, false),
NORM_L1,
1.00f);
test.safe_run();
}
TEST(Features2d_RotationInvariance_Descriptor_VGG80, regression)
{
DescriptorRotationInvarianceTest test(KAZE::create(),
VGG::create(VGG::VGG_80, 1.4f, true, true, 48.0f, false),
NORM_L1,
1.00f);
test.safe_run();
}
TEST(Features2d_RotationInvariance_Descriptor_VGG64, regression)
{
DescriptorRotationInvarianceTest test(KAZE::create(),
VGG::create(VGG::VGG_64, 1.4f, true, true, 48.0f, false),
NORM_L1,
1.00f);
test.safe_run();
}
TEST(Features2d_RotationInvariance_Descriptor_VGG48, regression)
{
DescriptorRotationInvarianceTest test(KAZE::create(),
VGG::create(VGG::VGG_48, 1.4f, true, true, 48.0f, false),
NORM_L1,
1.00f);
test.safe_run();
}
TEST(Features2d_RotationInvariance_Descriptor_BRIEF_64, regression)
{
DescriptorRotationInvarianceTest test(SURF::create(),
......@@ -774,3 +810,39 @@ TEST(DISABLED_Features2d_ScaleInvariance_Descriptor_DAISY, regression)
0.075f);
test.safe_run();
}
TEST(Features2d_ScaleInvariance_Descriptor_VGG120, regression)
{
DescriptorScaleInvarianceTest test(KAZE::create(),
VGG::create(VGG::VGG_120, 1.4f, true, true, 48.0f, false),
NORM_L1,
0.99f);
test.safe_run();
}
TEST(Features2d_ScaleInvariance_Descriptor_VGG80, regression)
{
DescriptorScaleInvarianceTest test(KAZE::create(),
VGG::create(VGG::VGG_80, 1.4f, true, true, 48.0f, false),
NORM_L1,
0.98f);
test.safe_run();
}
TEST(Features2d_ScaleInvariance_Descriptor_VGG64, regression)
{
DescriptorScaleInvarianceTest test(KAZE::create(),
VGG::create(VGG::VGG_64, 1.4f, true, true, 48.0f, false),
NORM_L1,
0.97f);
test.safe_run();
}
TEST(Features2d_ScaleInvariance_Descriptor_VGG48, regression)
{
DescriptorScaleInvarianceTest test(KAZE::create(),
VGG::create(VGG::VGG_48, 1.4f, true, true, 48.0f, false),
NORM_L1,
0.93f);
test.safe_run();
}
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