Commit 2a0cad77 authored by Yorwba's avatar Yorwba Committed by Alexander Alekhin

Merge pull request #933 from Yorwba:harris-laplace-detector

* Added files from http://code.opencv.org/issues/1053

The code structure had to be changed because of the
features2d/xfeatures2d split and to avoid changing
multiple modules (gaussian_pyramid doesn't seem ready
for inclusion in the (x)imgproc module).
Except for changes related to this, the patches
remain unchanged, including the outdated
copyright notice at the top of the files.

* Hide Harris-Laplace implementation behind pimpl-creating wrapper.

* Add test for Harris-Laplace feature detector.

* Handle empty images in Harris-Laplace detector.

* Replace HarrisAffineFeatureDetector with more flexible AffineFeature2D

* collapse unnecessary HarrisLaplace class into HarrisLaplaceFeatureDetector

* fold DoG pyramid code into harris_laplace_detector.cpp

* tuck auxiliary functions for Harris-Laplace into anonymous namespace

* use mask to filter keypoints in Harris-Laplace detector

* remove unused value of differentiation scale from calcAffineAdaptation

* make descriptor copy in AffineFeature2D independent of the data type

* Document interface for Harris-Laplace and AffineFeature2D

* Make type conversions explicit and decorate float literals with f in HarrisLaplace and AffineFeature2D

* Replace usage of non-standard log2 in Harris-Laplace feature detector

* Fix virtual overload errors in AffineFeature2D

* Add basic tests for AffineFeature2D and fix what they uncover

* Make type conversions in Harris-Laplace feature detector explicit

* Change license header for Harris-Laplace detector and AffineFeature2D

* Use Matx for small matrices in AffineFeature2D

* Remove redundant attributes of Elliptic_KeyPoint

* Convert Matx22f to Matx22d for inverting in AffineFeature2D
parent f36e5f92
...@@ -111,3 +111,14 @@ ...@@ -111,3 +111,14 @@
publisher = {{ACM}}, publisher = {{ACM}},
year = {2010} year = {2010}
} }
@article{Mikolajczyk2004,
title={Scale \& affine invariant interest point detectors},
author={Mikolajczyk, Krystian and Schmid, Cordelia},
journal={International journal of computer vision},
volume={60},
number={1},
pages={63--86},
year={2004},
publisher={Springer}
}
...@@ -834,6 +834,97 @@ public: ...@@ -834,6 +834,97 @@ public:
}; };
/**
* @brief Elliptic region around an interest point.
*/
class CV_EXPORTS Elliptic_KeyPoint : public KeyPoint
{
public:
Size_<float> axes; //!< the lengths of the major and minor ellipse axes
float si; //!< the integration scale at which the parameters were estimated
Matx23f transf; //!< the transformation between image space and local patch space
Elliptic_KeyPoint();
Elliptic_KeyPoint(Point2f pt, float angle, Size axes, float size, float si);
virtual ~Elliptic_KeyPoint();
};
/**
* @brief Class implementing the Harris-Laplace feature detector as described in @cite Mikolajczyk2004.
*/
class CV_EXPORTS_W HarrisLaplaceFeatureDetector : public Feature2D
{
public:
/**
* @brief Creates a new implementation instance.
*
* @param numOctaves the number of octaves in the scale-space pyramid
* @param corn_thresh the threshold for the Harris cornerness measure
* @param DOG_thresh the threshold for the Difference-of-Gaussians scale selection
* @param maxCorners the maximum number of corners to consider
* @param num_layers the number of intermediate scales per octave
*/
CV_WRAP static Ptr<HarrisLaplaceFeatureDetector> create(
int numOctaves=6,
float corn_thresh=0.01f,
float DOG_thresh=0.01f,
int maxCorners=5000,
int num_layers=4);
};
/**
* @brief Class implementing affine adaptation for key points.
*
* A @ref FeatureDetector and a @ref DescriptorExtractor are wrapped to augment the
* detected points with their affine invariant elliptic region and to compute
* the feature descriptors on the regions after warping them into circles.
*
* The interface is equivalent to @ref Feature2D, adding operations for
* @ref Elliptic_KeyPoint "Elliptic_KeyPoints" instead of @ref KeyPoint "KeyPoints".
*/
class CV_EXPORTS AffineFeature2D : public Feature2D
{
public:
/**
* @brief Creates an instance wrapping the given keypoint detector and
* descriptor extractor.
*/
static Ptr<AffineFeature2D> create(
Ptr<FeatureDetector> keypoint_detector,
Ptr<DescriptorExtractor> descriptor_extractor);
/**
* @brief Creates an instance where keypoint detector and descriptor
* extractor are identical.
*/
static Ptr<AffineFeature2D> create(
Ptr<FeatureDetector> keypoint_detector)
{
return create(keypoint_detector, keypoint_detector);
}
using Feature2D::detect; // overload, don't hide
/**
* @brief Detects keypoints in the image using the wrapped detector and
* performs affine adaptation to augment them with their elliptic regions.
*/
virtual void detect(
InputArray image,
CV_OUT std::vector<Elliptic_KeyPoint>& keypoints,
InputArray mask=noArray() ) = 0;
using Feature2D::detectAndCompute; // overload, don't hide
/**
* @brief Detects keypoints and computes descriptors for their surrounding
* regions, after warping them into circles.
*/
virtual void detectAndCompute(
InputArray image,
InputArray mask,
CV_OUT std::vector<Elliptic_KeyPoint>& keypoints,
OutputArray descriptors,
bool useProvidedKeypoints=false ) = 0;
};
//! @} //! @}
} }
......
This diff is collapsed.
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
#include "precomp.hpp"
namespace cv {
namespace xfeatures2d {
Elliptic_KeyPoint::Elliptic_KeyPoint(Point2f _pt, float _angle, Size _axes, float _size, float _si) :
KeyPoint(_pt,_size,_angle), axes(_axes), si(_si) {
}
Elliptic_KeyPoint::Elliptic_KeyPoint(){
}
Elliptic_KeyPoint::~Elliptic_KeyPoint() {
}
}
}
This diff is collapsed.
...@@ -997,6 +997,24 @@ TEST( Features2d_Detector_STAR, regression ) ...@@ -997,6 +997,24 @@ TEST( Features2d_Detector_STAR, regression )
test.safe_run(); test.safe_run();
} }
TEST( Features2d_Detector_Harris_Laplace, regression )
{
CV_FeatureDetectorTest test( "detector-harris-laplace", HarrisLaplaceFeatureDetector::create() );
test.safe_run();
}
TEST( Features2d_Detector_Harris_Laplace_Affine_Keypoint_Invariance, regression )
{
CV_FeatureDetectorTest test( "detector-harris-laplace", AffineFeature2D::create(HarrisLaplaceFeatureDetector::create()));
test.safe_run();
}
TEST( Features2d_Detector_Harris_Laplace_Affine, regression )
{
CV_FeatureDetectorTest test( "detector-harris-laplace-affine", AffineFeature2D::create(HarrisLaplaceFeatureDetector::create()));
test.safe_run();
}
/* /*
* Descriptors * Descriptors
*/ */
......
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