2011-02-22 21:43:26 +01:00
Common Interfaces of Feature Detectors
======================================
2011-04-19 13:41:12 +02:00
.. highlight :: cpp
2011-05-04 21:22:51 +02:00
Feature detectors in OpenCV have wrappers with a common interface that enables you to easily switch
2011-02-26 12:05:10 +01:00
between different algorithms solving the same problem. All objects that implement keypoint detectors
2011-05-04 21:22:51 +02:00
inherit the
2011-06-23 14:00:09 +02:00
:ocv:class: `FeatureDetector` interface.
2011-02-22 21:43:26 +01:00
2013-08-06 16:24:09 +02:00
.. note ::
2013-07-29 15:51:16 +02:00
2013-08-06 16:24:09 +02:00
* An example explaining keypoint detection can be found at opencv_source_code/samples/cpp/descriptor_extractor_matcher.cpp
2013-07-29 15:51:16 +02:00
2011-02-22 21:43:26 +01:00
KeyPoint
--------
2011-06-16 14:48:23 +02:00
.. ocv:class :: KeyPoint
2011-02-22 21:43:26 +01:00
2012-05-29 18:55:46 +02:00
Data structure for salient point detectors.
2011-06-30 00:06:42 +02:00
2012-05-29 18:55:46 +02:00
.. ocv:member :: Point2f pt
2012-03-29 10:07:57 +02:00
2012-05-29 18:55:46 +02:00
coordinates of the keypoint
2012-03-29 10:07:57 +02:00
2012-05-29 18:55:46 +02:00
.. ocv:member :: float size
2012-03-29 10:07:57 +02:00
2012-05-29 18:55:46 +02:00
diameter of the meaningful keypoint neighborhood
2012-03-29 10:07:57 +02:00
2012-05-29 18:55:46 +02:00
.. ocv:member :: float angle
2012-03-29 10:07:57 +02:00
2012-07-14 17:36:35 +02:00
computed orientation of the keypoint (-1 if not applicable). Its possible values are in a range [0,360) degrees. It is measured relative to image coordinate system (y-axis is directed downward), ie in clockwise.
2012-03-29 10:07:57 +02:00
2012-05-29 18:55:46 +02:00
.. ocv:member :: float response
2012-03-29 10:07:57 +02:00
2012-05-29 18:55:46 +02:00
the response by which the most strong keypoints have been selected. Can be used for further sorting or subsampling
2012-03-29 10:07:57 +02:00
2012-05-29 18:55:46 +02:00
.. ocv:member :: int octave
2012-03-29 10:07:57 +02:00
2012-05-29 18:55:46 +02:00
octave (pyramid layer) from which the keypoint has been extracted
2012-03-29 10:07:57 +02:00
2012-05-29 18:55:46 +02:00
.. ocv:member :: int class_id
2012-03-29 10:07:57 +02:00
2012-05-29 18:55:46 +02:00
object id that can be used to clustered keypoints by an object they belong to
2011-06-30 00:06:42 +02:00
KeyPoint::KeyPoint
------------------
The keypoint constructors
.. ocv:function :: KeyPoint::KeyPoint()
.. ocv:function :: KeyPoint::KeyPoint(Point2f _pt, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1)
.. ocv:function :: KeyPoint::KeyPoint(float x, float y, float _size, float _angle=-1, float _response=0, int _octave=0, int _class_id=-1)
2012-05-28 09:36:14 +02:00
.. ocv:pyfunction :: cv2.KeyPoint([x, y, _size[, _angle[, _response[, _octave[, _class_id]]]]]) -> <KeyPoint object>
2011-06-30 00:06:42 +02:00
:param x: x-coordinate of the keypoint
2012-03-29 10:07:57 +02:00
2011-06-30 00:06:42 +02:00
:param y: y-coordinate of the keypoint
2012-03-29 10:07:57 +02:00
2011-06-30 00:06:42 +02:00
:param _pt: x & y coordinates of the keypoint
2012-03-29 10:07:57 +02:00
2011-06-30 00:06:42 +02:00
:param _size: keypoint diameter
2012-03-29 10:07:57 +02:00
2011-06-30 00:06:42 +02:00
:param _angle: keypoint orientation
2012-03-29 10:07:57 +02:00
2011-06-30 00:06:42 +02:00
:param _response: keypoint detector response on the keypoint (that is, strength of the keypoint)
2012-03-29 10:07:57 +02:00
2011-06-30 00:06:42 +02:00
:param _octave: pyramid octave in which the keypoint has been detected
2012-03-29 10:07:57 +02:00
2011-06-30 00:06:42 +02:00
:param _class_id: object id
2011-02-22 21:43:26 +01:00
2011-04-19 13:41:12 +02:00
2011-02-22 21:43:26 +01:00
FeatureDetector
---------------
2012-05-28 09:36:14 +02:00
.. ocv:class :: FeatureDetector : public Algorithm
2011-02-22 21:43:26 +01:00
2011-06-23 14:00:09 +02:00
Abstract base class for 2D image feature detectors. ::
2011-02-22 21:43:26 +01:00
class CV_EXPORTS FeatureDetector
{
public:
virtual ~FeatureDetector();
2011-02-26 12:05:10 +01:00
void detect( const Mat& image, vector<KeyPoint>& keypoints,
2011-02-22 21:43:26 +01:00
const Mat& mask=Mat() ) const;
2011-02-26 12:05:10 +01:00
void detect( const vector<Mat>& images,
vector<vector<KeyPoint> >& keypoints,
2011-02-22 21:43:26 +01:00
const vector<Mat>& masks=vector<Mat>() ) const;
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
virtual void read(const FileNode&);
virtual void write(FileStorage&) const;
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
static Ptr<FeatureDetector> create( const string& detectorType );
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
protected:
...
};
2011-03-03 08:29:55 +01:00
2011-02-28 22:26:43 +01:00
FeatureDetector::detect
2011-02-22 21:43:26 +01:00
---------------------------
2011-06-30 00:06:42 +02:00
Detects keypoints in an image (first variant) or image set (second variant).
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
.. ocv:function :: void FeatureDetector::detect( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const
2011-02-22 21:43:26 +01:00
2011-07-22 14:50:49 +02:00
.. ocv:function :: void FeatureDetector::detect( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints, const vector<Mat>& masks=vector<Mat>() ) const
2011-02-22 21:43:26 +01:00
2011-07-22 14:50:49 +02:00
:param image: Image.
2011-02-22 21:43:26 +01:00
2011-05-04 21:22:51 +02:00
:param images: Image set.
2011-02-22 21:43:26 +01:00
2011-07-22 14:50:49 +02:00
:param keypoints: The detected keypoints. In the second variant of the method ``keypoints[i]`` is a set of keypoints detected in ``images[i]`` .
:param mask: Mask specifying where to look for keypoints (optional). It must be a 8-bit integer matrix with non-zero values in the region of interest.
2011-02-22 21:43:26 +01:00
2011-07-22 14:50:49 +02:00
:param masks: Masks for each input image specifying where to look for keypoints (optional). ``masks[i]`` is a mask for ``images[i]``.
2011-02-22 21:43:26 +01:00
2011-02-28 22:26:43 +01:00
FeatureDetector::create
2013-01-13 13:27:11 +01:00
-----------------------
2011-06-30 00:06:42 +02:00
Creates a feature detector by its name.
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
.. ocv:function :: Ptr<FeatureDetector> FeatureDetector::create( const string& detectorType )
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param detectorType: Feature detector type.
2011-02-22 21:43:26 +01:00
2011-05-04 21:22:51 +02:00
The following detector types are supported:
2011-06-23 14:00:09 +02:00
* `` "FAST" `` -- :ocv:class: `FastFeatureDetector`
* `` "STAR" `` -- :ocv:class: `StarFeatureDetector`
2012-04-30 16:33:52 +02:00
* `` "SIFT" `` -- :ocv:class: `SIFT` (nonfree module)
* `` "SURF" `` -- :ocv:class: `SURF` (nonfree module)
* `` "ORB" `` -- :ocv:class: `ORB`
2013-02-03 14:31:15 +01:00
* `` "BRISK" `` -- :ocv:class: `BRISK`
2012-04-30 16:33:52 +02:00
* `` "MSER" `` -- :ocv:class: `MSER`
2011-08-13 18:49:40 +02:00
* `` "GFTT" `` -- :ocv:class: `GoodFeaturesToTrackDetector`
* `` "HARRIS" `` -- :ocv:class: `GoodFeaturesToTrackDetector` with Harris detector enabled
* `` "Dense" `` -- :ocv:class: `DenseFeatureDetector`
* `` "SimpleBlob" `` -- :ocv:class: `SimpleBlobDetector`
2011-05-04 21:22:51 +02:00
Also a combined format is supported: feature detector adapter name ( `` "Grid" `` --
2011-06-23 14:00:09 +02:00
:ocv:class: `GridAdaptedFeatureDetector` , `` "Pyramid" `` --
:ocv:class: `PyramidAdaptedFeatureDetector` ) + feature detector name (see above),
2011-05-08 17:30:00 +02:00
for example: `` "GridFAST" `` , `` "PyramidSTAR" `` .
2011-02-22 21:43:26 +01:00
FastFeatureDetector
-------------------
2012-05-28 09:36:14 +02:00
.. ocv:class :: FastFeatureDetector : public FeatureDetector
2011-02-22 21:43:26 +01:00
2011-05-04 21:22:51 +02:00
Wrapping class for feature detection using the
2011-06-23 14:00:09 +02:00
:ocv:func: `FAST` method. ::
2011-02-22 21:43:26 +01:00
class FastFeatureDetector : public FeatureDetector
{
public:
2012-08-07 16:17:30 +02:00
FastFeatureDetector( int threshold=1, bool nonmaxSuppression=true, type=FastFeatureDetector::TYPE_9_16 );
2011-02-22 21:43:26 +01:00
virtual void read( const FileNode& fn );
virtual void write( FileStorage& fs ) const;
protected:
...
};
2011-03-03 08:29:55 +01:00
2011-02-22 21:43:26 +01:00
GoodFeaturesToTrackDetector
---------------------------
2012-05-28 16:36:15 +02:00
.. ocv:class :: GoodFeaturesToTrackDetector : public FeatureDetector
2011-02-22 21:43:26 +01:00
2011-05-04 21:22:51 +02:00
Wrapping class for feature detection using the
2011-06-23 14:00:09 +02:00
:ocv:func: `goodFeaturesToTrack` function. ::
2011-02-22 21:43:26 +01:00
class GoodFeaturesToTrackDetector : public FeatureDetector
{
public:
class Params
{
public:
2011-02-26 12:05:10 +01:00
Params( int maxCorners=1000, double qualityLevel=0.01,
double minDistance=1., int blockSize=3,
2011-02-22 21:43:26 +01:00
bool useHarrisDetector=false, double k=0.04 );
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
int maxCorners;
double qualityLevel;
double minDistance;
int blockSize;
bool useHarrisDetector;
double k;
};
2011-02-26 12:05:10 +01:00
2011-02-22 21:43:26 +01:00
GoodFeaturesToTrackDetector( const GoodFeaturesToTrackDetector::Params& params=
GoodFeaturesToTrackDetector::Params() );
2011-02-26 12:05:10 +01:00
GoodFeaturesToTrackDetector( int maxCorners, double qualityLevel,
double minDistance, int blockSize=3,
2011-02-22 21:43:26 +01:00
bool useHarrisDetector=false, double k=0.04 );
virtual void read( const FileNode& fn );
virtual void write( FileStorage& fs ) const;
protected:
...
};
2011-03-03 08:29:55 +01:00
2011-02-22 21:43:26 +01:00
MserFeatureDetector
-------------------
2012-05-28 16:36:15 +02:00
.. ocv:class :: MserFeatureDetector : public FeatureDetector
2011-02-22 21:43:26 +01:00
2011-05-04 21:22:51 +02:00
Wrapping class for feature detection using the
2011-06-23 14:00:09 +02:00
:ocv:class: `MSER` class. ::
2011-02-22 21:43:26 +01:00
class MserFeatureDetector : public FeatureDetector
{
public:
MserFeatureDetector( CvMSERParams params=cvMSERParams() );
2011-02-26 12:05:10 +01:00
MserFeatureDetector( int delta, int minArea, int maxArea,
2011-02-22 21:43:26 +01:00
double maxVariation, double minDiversity,
2011-02-26 12:05:10 +01:00
int maxEvolution, double areaThreshold,
2011-02-22 21:43:26 +01:00
double minMargin, int edgeBlurSize );
virtual void read( const FileNode& fn );
virtual void write( FileStorage& fs ) const;
protected:
...
};
2011-03-03 08:29:55 +01:00
2011-02-22 21:43:26 +01:00
StarFeatureDetector
-------------------
2012-05-28 16:36:15 +02:00
.. ocv:class :: StarFeatureDetector : public FeatureDetector
2011-02-22 21:43:26 +01:00
2013-07-23 09:49:09 +02:00
The class implements the keypoint detector introduced by [Agrawal08]_ , synonym of `` StarDetector `` . ::
2011-02-22 21:43:26 +01:00
class StarFeatureDetector : public FeatureDetector
{
public:
2011-02-26 12:05:10 +01:00
StarFeatureDetector( int maxSize=16, int responseThreshold=30,
2011-02-22 21:43:26 +01:00
int lineThresholdProjected = 10,
int lineThresholdBinarized=8, int suppressNonmaxSize=5 );
virtual void read( const FileNode& fn );
virtual void write( FileStorage& fs ) const;
protected:
...
};
2011-03-03 08:29:55 +01:00
2013-07-23 08:49:25 +02:00
.. [Agrawal08] Agrawal, M., Konolige, K., & Blas, M. R. (2008). Censure: Center surround extremas for realtime feature detection and matching. In Computer Vision– ECCV 2008 (pp. 102-115). Springer Berlin Heidelberg.
2012-03-28 11:39:40 +02:00
DenseFeatureDetector
--------------------
2012-05-28 09:36:14 +02:00
.. ocv:class :: DenseFeatureDetector : public FeatureDetector
2012-03-28 11:39:40 +02:00
Class for generation of image features which are distributed densely and regularly over the image. ::
2012-03-29 10:07:57 +02:00
class DenseFeatureDetector : public FeatureDetector
{
public:
DenseFeatureDetector( float initFeatureScale=1.f, int featureScaleLevels=1,
2012-03-28 11:39:40 +02:00
float featureScaleMul=0.1f,
int initXyStep=6, int initImgBound=0,
bool varyXyStepWithScale=true,
bool varyImgBoundWithScale=false );
2012-03-29 10:07:57 +02:00
protected:
2012-03-28 11:39:40 +02:00
...
};
2012-03-29 10:07:57 +02:00
2012-03-28 11:39:40 +02:00
The detector generates several levels (in the amount of `` featureScaleLevels `` ) of features. Features of each level are located in the nodes of a regular grid over the image (excluding the image boundary of given size). The level parameters (a feature scale, a node size, a size of boundary) are multiplied by `` featureScaleMul `` with level index growing depending on input flags, viz.:
* Feature scale is multiplied always.
* The grid node size is multiplied if `` varyXyStepWithScale `` is `` true `` .
* Size of image boundary is multiplied if `` varyImgBoundWithScale `` is `` true `` .
2011-05-21 00:25:53 +02:00
2011-06-09 17:20:55 +02:00
SimpleBlobDetector
-------------------
2012-05-28 09:36:14 +02:00
.. ocv:class :: SimpleBlobDetector : public FeatureDetector
2011-06-09 17:20:55 +02:00
2011-06-23 14:00:09 +02:00
Class for extracting blobs from an image. ::
2011-06-09 17:20:55 +02:00
class SimpleBlobDetector : public FeatureDetector
{
public:
struct Params
{
Params();
float thresholdStep;
float minThreshold;
float maxThreshold;
size_t minRepeatability;
float minDistBetweenBlobs;
bool filterByColor;
uchar blobColor;
bool filterByArea;
float minArea, maxArea;
bool filterByCircularity;
float minCircularity, maxCircularity;
bool filterByInertia;
float minInertiaRatio, maxInertiaRatio;
bool filterByConvexity;
float minConvexity, maxConvexity;
};
SimpleBlobDetector(const SimpleBlobDetector::Params ¶meters = SimpleBlobDetector::Params());
protected:
...
};
2011-06-23 14:00:09 +02:00
The class implements a simple algorithm for extracting blobs from an image:
2012-03-29 10:07:57 +02:00
#. Convert the source image to binary images by applying thresholding with several thresholds from `` minThreshold `` (inclusive) to `` maxThreshold `` (exclusive) with distance `` thresholdStep `` between neighboring thresholds.
2011-06-23 14:00:09 +02:00
2012-03-29 10:07:57 +02:00
#. Extract connected components from every binary image by :ocv:func: `findContours` and calculate their centers.
2011-06-23 14:00:09 +02:00
2012-03-29 10:07:57 +02:00
#. Group centers from several binary images by their coordinates. Close centers form one group that corresponds to one blob, which is controlled by the `` minDistBetweenBlobs `` parameter.
2011-06-23 14:00:09 +02:00
#. From the groups, estimate final centers of blobs and their radiuses and return as locations and sizes of keypoints.
2011-06-09 17:20:55 +02:00
This class performs several filtrations of returned blobs. You should set `` filterBy* `` to true/false to turn on/off corresponding filtration. Available filtrations:
2011-06-23 14:00:09 +02:00
* **By color** . This filter compares the intensity of a binary image at the center of a blob to `` blobColor `` . If they differ, the blob is filtered out. Use `` blobColor = 0 `` to extract dark blobs and `` blobColor = 255 `` to extract light blobs.
2011-06-09 17:20:55 +02:00
2011-06-23 14:00:09 +02:00
* **By area** . Extracted blobs have an area between `` minArea `` (inclusive) and `` maxArea `` (exclusive).
2011-06-09 17:20:55 +02:00
2011-06-23 14:00:09 +02:00
* **By circularity** . Extracted blobs have circularity (:math: `\frac{4*\pi*Area}{perimeter * perimeter}` ) between `` minCircularity `` (inclusive) and `` maxCircularity `` (exclusive).
2011-06-09 17:20:55 +02:00
2011-06-23 14:00:09 +02:00
* **By ratio of the minimum inertia to maximum inertia** . Extracted blobs have this ratio between `` minInertiaRatio `` (inclusive) and `` maxInertiaRatio `` (exclusive).
2011-06-09 17:20:55 +02:00
2011-06-23 14:00:09 +02:00
* **By convexity** . Extracted blobs have convexity (area / area of blob convex hull) between `` minConvexity `` (inclusive) and `` maxConvexity `` (exclusive).
2011-06-09 17:20:55 +02:00
Default values of parameters are tuned to extract dark circular blobs.
2011-02-22 21:43:26 +01:00
GridAdaptedFeatureDetector
--------------------------
2012-05-28 09:36:14 +02:00
.. ocv:class :: GridAdaptedFeatureDetector : public FeatureDetector
2011-02-22 21:43:26 +01:00
2011-06-23 14:00:09 +02:00
Class adapting a detector to partition the source image into a grid and detect points in each cell. ::
2011-02-22 21:43:26 +01:00
class GridAdaptedFeatureDetector : public FeatureDetector
{
public:
/*
* detector Detector that will be adapted.
2011-02-26 12:05:10 +01:00
* maxTotalKeypoints Maximum count of keypoints detected on the image.
2011-05-04 21:22:51 +02:00
* Only the strongest keypoints will be kept.
* gridRows Grid row count.
2011-02-22 21:43:26 +01:00
* gridCols Grid column count.
*/
2011-02-26 12:05:10 +01:00
GridAdaptedFeatureDetector( const Ptr<FeatureDetector>& detector,
int maxTotalKeypoints, int gridRows=4,
2011-02-22 21:43:26 +01:00
int gridCols=4 );
virtual void read( const FileNode& fn );
virtual void write( FileStorage& fs ) const;
protected:
...
};
2011-03-03 08:29:55 +01:00
2011-02-22 21:43:26 +01:00
PyramidAdaptedFeatureDetector
-----------------------------
2012-05-28 09:36:14 +02:00
.. ocv:class :: PyramidAdaptedFeatureDetector : public FeatureDetector
2011-02-22 21:43:26 +01:00
2011-05-04 21:22:51 +02:00
Class adapting a detector to detect points over multiple levels of a Gaussian pyramid. Consider using this class for detectors that are not inherently scaled. ::
2011-02-22 21:43:26 +01:00
class PyramidAdaptedFeatureDetector : public FeatureDetector
{
public:
2011-02-26 12:05:10 +01:00
PyramidAdaptedFeatureDetector( const Ptr<FeatureDetector>& detector,
2011-02-22 21:43:26 +01:00
int levels=2 );
virtual void read( const FileNode& fn );
virtual void write( FileStorage& fs ) const;
protected:
...
};
DynamicAdaptedFeatureDetector
-----------------------------
2012-05-28 09:36:14 +02:00
.. ocv:class :: DynamicAdaptedFeatureDetector : public FeatureDetector
2011-02-22 21:43:26 +01:00
2011-06-23 14:00:09 +02:00
Adaptively adjusting detector that iteratively detects features until the desired number is found. ::
2011-03-03 08:29:55 +01:00
class DynamicAdaptedFeatureDetector: public FeatureDetector
{
public:
2011-05-12 01:31:50 +02:00
DynamicAdaptedFeatureDetector( const Ptr<AdjusterAdapter>& adjuster,
2011-03-03 08:29:55 +01:00
int min_features=400, int max_features=500, int max_iters=5 );
...
};
2011-02-22 21:43:26 +01:00
2011-05-08 17:30:00 +02:00
If the detector is persisted, it "remembers" the parameters
2011-05-04 21:22:51 +02:00
used for the last detection. In this case, the detector may be used for consistent numbers
of keypoints in a set of temporally related images, such as video streams or
2011-02-22 21:43:26 +01:00
panorama series.
2011-06-23 14:00:09 +02:00
`` DynamicAdaptedFeatureDetector `` uses another detector, such as FAST or SURF, to do the dirty work,
2011-05-04 21:22:51 +02:00
with the help of `` AdjusterAdapter `` .
2011-05-12 01:31:50 +02:00
If the detected number of features is not large enough,
2012-03-29 10:07:57 +02:00
`` AdjusterAdapter `` adjusts the detection parameters so that the next detection
2011-05-15 22:56:53 +02:00
results in a bigger or smaller number of features. This is repeated until either the number of desired features are found
2011-02-22 21:43:26 +01:00
or the parameters are maxed out.
2011-05-04 21:22:51 +02:00
Adapters can be easily implemented for any detector via the
`` AdjusterAdapter `` interface.
2011-02-22 21:43:26 +01:00
2011-05-12 01:31:50 +02:00
Beware that this is not thread-safe since the adjustment of parameters requires modification of the feature detector class instance.
2011-02-22 21:43:26 +01:00
2011-05-08 17:30:00 +02:00
Example of creating `` DynamicAdaptedFeatureDetector `` : ::
2011-02-22 21:43:26 +01:00
//sample usage:
2011-02-26 12:05:10 +01:00
//will create a detector that attempts to find
2011-02-22 21:43:26 +01:00
//100 - 110 FAST Keypoints, and will at most run
2011-02-26 12:05:10 +01:00
//FAST feature detection 10 times until that
2011-02-22 21:43:26 +01:00
//number of keypoints are found
Ptr<FeatureDetector> detector(new DynamicAdaptedFeatureDetector (100, 110, 10,
new FastAdjuster(20,true)));
2011-03-03 08:29:55 +01:00
2011-06-23 14:00:09 +02:00
2011-03-03 08:29:55 +01:00
DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector
2013-01-13 13:27:11 +01:00
------------------------------------------------------------
2011-06-30 00:06:42 +02:00
The constructor
2011-03-03 08:29:55 +01:00
2012-05-29 12:36:19 +02:00
.. ocv:function :: DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector( const Ptr<AdjusterAdapter>& adjuster, int min_features=400, int max_features=500, int max_iters=5 )
2011-03-03 08:29:55 +01:00
2011-06-23 14:00:09 +02:00
:param adjuster: :ocv:class:`AdjusterAdapter` that detects features and adjusts parameters.
2011-03-03 08:29:55 +01:00
2011-05-08 17:30:00 +02:00
:param min_features: Minimum desired number of features.
2011-03-03 08:29:55 +01:00
2011-05-04 21:22:51 +02:00
:param max_features: Maximum desired number of features.
2011-03-03 08:29:55 +01:00
2012-04-13 23:50:59 +02:00
:param max_iters: Maximum number of times to try adjusting the feature detector parameters. For :ocv:class:`FastAdjuster` , this number can be high, but with ``Star`` or ``Surf`` many iterations can be time-consuming. At each iteration the detector is rerun.
2011-03-03 08:29:55 +01:00
AdjusterAdapter
---------------
2012-05-28 09:36:14 +02:00
.. ocv:class :: AdjusterAdapter : public FeatureDetector
2011-03-03 08:29:55 +01:00
2011-06-23 14:00:09 +02:00
Class providing an interface for adjusting parameters of a feature detector. This interface is used by :ocv:class: `DynamicAdaptedFeatureDetector` . It is a wrapper for :ocv:class: `FeatureDetector` that enables adjusting parameters after feature detection. ::
2012-03-29 10:07:57 +02:00
2011-03-03 08:29:55 +01:00
class AdjusterAdapter: public FeatureDetector
{
public:
2011-06-17 15:23:28 +02:00
virtual ~AdjusterAdapter() {}
virtual void tooFew(int min, int n_detected) = 0;
virtual void tooMany(int max, int n_detected) = 0;
virtual bool good() const = 0;
virtual Ptr<AdjusterAdapter> clone() const = 0;
static Ptr<AdjusterAdapter> create( const string& detectorType );
2011-03-03 08:29:55 +01:00
};
See
2011-06-23 14:00:09 +02:00
:ocv:class: `FastAdjuster` ,
:ocv:class: `StarAdjuster` , and
:ocv:class: `SurfAdjuster` for concrete implementations.
2011-03-03 08:29:55 +01:00
AdjusterAdapter::tooFew
---------------------------
2011-06-30 00:06:42 +02:00
Adjusts the detector parameters to detect more features.
2011-03-03 08:29:55 +01:00
2011-06-30 00:06:42 +02:00
.. ocv:function :: void AdjusterAdapter::tooFew(int min, int n_detected)
2011-03-03 08:29:55 +01:00
2011-05-04 21:22:51 +02:00
:param min: Minimum desired number of features.
2011-03-03 08:29:55 +01:00
2011-05-04 21:22:51 +02:00
:param n_detected: Number of features detected during the latest run.
2011-03-03 08:29:55 +01:00
2011-05-04 21:22:51 +02:00
Example: ::
2011-03-03 08:29:55 +01:00
void FastAdjuster::tooFew(int min, int n_detected)
{
thresh_--;
}
AdjusterAdapter::tooMany
----------------------------
2011-06-30 00:06:42 +02:00
Adjusts the detector parameters to detect less features.
2011-03-03 08:29:55 +01:00
2011-06-30 00:06:42 +02:00
.. ocv:function :: void AdjusterAdapter::tooMany(int max, int n_detected)
2011-03-03 08:29:55 +01:00
2011-05-04 21:22:51 +02:00
:param max: Maximum desired number of features.
2011-03-03 08:29:55 +01:00
2011-05-04 21:22:51 +02:00
:param n_detected: Number of features detected during the latest run.
2011-03-03 08:29:55 +01:00
2011-05-04 21:22:51 +02:00
Example: ::
2011-03-03 08:29:55 +01:00
void FastAdjuster::tooMany(int min, int n_detected)
{
thresh_++;
}
AdjusterAdapter::good
2013-01-13 13:27:11 +01:00
---------------------
2012-03-29 10:07:57 +02:00
Returns false if the detector parameters cannot be adjusted any more.
2011-03-03 08:29:55 +01:00
2011-06-30 00:06:42 +02:00
.. ocv:function :: bool AdjusterAdapter::good() const
2011-05-04 21:22:51 +02:00
Example: ::
2011-03-03 08:29:55 +01:00
bool FastAdjuster::good() const
{
return (thresh_ > 1) && (thresh_ < 200);
}
2011-06-17 15:23:28 +02:00
AdjusterAdapter::create
2013-01-13 13:27:11 +01:00
-----------------------
2011-06-30 00:06:42 +02:00
Creates an adjuster adapter by name
2011-06-17 15:23:28 +02:00
.. ocv:function :: Ptr<AdjusterAdapter> AdjusterAdapter::create( const string& detectorType )
2011-03-03 08:29:55 +01:00
2011-06-23 14:00:09 +02:00
Creates an adjuster adapter by name `` detectorType `` . The detector name is the same as in :ocv:func: `FeatureDetector::create` , but now supports `` "FAST" `` , `` "STAR" `` , and `` "SURF" `` only.
2011-03-03 08:29:55 +01:00
FastAdjuster
------------
2012-05-28 09:36:14 +02:00
.. ocv:class :: FastAdjuster : public AdjusterAdapter
2011-03-03 08:29:55 +01:00
2011-06-23 14:00:09 +02:00
:ocv:class: `AdjusterAdapter` for :ocv:class: `FastFeatureDetector` . This class decreases or increases the threshold value by 1. ::
2011-03-03 08:29:55 +01:00
class FastAdjuster FastAdjuster: public AdjusterAdapter
{
public:
FastAdjuster(int init_thresh = 20, bool nonmax = true);
...
};
StarAdjuster
------------
2012-05-28 09:36:14 +02:00
.. ocv:class :: StarAdjuster : public AdjusterAdapter
2011-03-03 08:29:55 +01:00
2011-06-23 14:00:09 +02:00
:ocv:class: `AdjusterAdapter` for :ocv:class: `StarFeatureDetector` . This class adjusts the `` responseThreshhold `` of `` StarFeatureDetector `` . ::
2011-03-03 08:29:55 +01:00
class StarAdjuster: public AdjusterAdapter
{
StarAdjuster(double initial_thresh = 30.0);
...
};
2013-01-13 13:27:11 +01:00
SurfAdjuster
------------
2013-02-19 09:01:27 +01:00
.. ocv:class :: SurfAdjuster : public AdjusterAdapter
2013-01-13 13:27:11 +01:00
:ocv:class: `AdjusterAdapter` for `` SurfFeatureDetector `` . ::
class CV_EXPORTS SurfAdjuster: public AdjusterAdapter
{
public:
SurfAdjuster( double initial_thresh=400.f, double min_thresh=2, double max_thresh=1000 );
virtual void tooFew(int minv, int n_detected);
virtual void tooMany(int maxv, int n_detected);
virtual bool good() const;
virtual Ptr<AdjusterAdapter> clone() const;
...
};