Learning OpenCV 3 by Adrian Kaehler & Gary Bradski

Learning OpenCV 3 by Adrian Kaehler & Gary Bradski

Author:Adrian Kaehler & Gary Bradski
Language: eng
Format: epub
Publisher: O'Reilly Media, Inc.
Published: 2016-12-27T16:00:00+00:00


Keypoint finder

Start by taking a look at (a somewhat simplified version of) the blob detector’s declaration:

class SimpleBlobDetector : public Feature2D { public: struct Params { Params(); float minThreshold; // First threshold to use float maxThreshold; // Highest threshold to use float thresholdStep; // Step between thresholds size_t minRepeatability; // Blob must appear // in this many images float minDistBetweenBlobs; // Blob must be this far // from others bool filterByColor; // True to use color filter uchar blobColor; // always 0 or 255 bool filterByArea; // True to use area filter float minArea, maxArea; // min and max area to accept // True to filter on "circularity", and min/max // ratio to circle area bool filterByCircularity; float minCircularity, maxCircularity; // True to filter on "inertia", and min/max eigenvalue ratio bool filterByInertia; float minInertiaRatio, maxInertiaRatio; // True to filter on convexity, and min/max ratio to hull area bool filterByConvexity; float minConvexity, maxConvexity; void read( const FileNode& fn ); void write( FileStorage& fs ) const; }; static Ptr<SimpleBlobDetector> create( const SimpleBlobDetector::Params &parameters = SimpleBlobDetector::Params() ); virtual void read( const FileNode& fn ); virtual void write( FileStorage& fs ) const; ... };

As you can see from scanning over this declaration, it is clear that there is not actually much going on here. There is a definition for cv::SimpleBlobDetector::Params, a structure that can hold all of the information needed to actually run a simple blob detector, a constructor (which takes a Params argument), and read() and write() functions that will allow us to store the state of our detector. Of course, there are also the all-important detect() routines inherited from the cv::Feature2D interface.

We already know how the detect() member works, in the sense that what it does is entirely generic to all feature detectors; what really matters to us here is how to set up the parameters in the Params argument to the constructor. The first group of five parameters controls the basic functioning of the algorithm. We use thresholdStep, minThreshold, and maxThreshold to configure the set of thresholded images to generate. We do so by starting at minThreshold and stepping up by thresholdStep each time up until, but not including, maxThreshold. It is typical to start with a value around 50 to 64 and step in small increments (e.g., 10) up to about 220 to 235, thus avoiding the often-less-informative ends of the intensity distribution. minRepeatability determines how many (consecutive) threshold images must contain overlapping blob candidates in order for the candidates to be combined into a blob. This number is typically a small integer, but rarely less than two. The actual meaning of “overlapping” is controlled by minDistBetweenBlobs. If two blob candidates have their centers within this distance, they are considered to be related to the same blob. Keep in mind that this one is in pixel units, and so should scale with your image. The default constructor for cv::SimpleBlobDetector::Params sets this to 10, which is probably only suitable for images of about 640 × 480.

The remaining parameters affect the different filtering



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.