Features
Interest points
Interest points are sudden changes in intensity in the region. These local features are usually classified as edges, blobs or corners.
List of methods to detect features
List of methods in OpenCV to detect features or interest points or key points
Normal Feature detectors
- Harris corner detector
- FAST feature detector
- feature detector class
- Adapted feature detection
- Grid Adapted feature detection
- Pyramid Adapted feature detection
Scale invariance Feature detectors
Detect same features regardless of scale of the image
- SIFT
- SURF
- BRISK (Binary Robust Invariant Scalable Keypoints)
- ORB (Oriented FAST Rotated BRISK)
I have tried only 2 methods
- FAST
- BRISK
FAST Feature Detector
Working : It works by selecting a candidate point the forming a circle using radius of 3 pixels
then it tests all the pixels in the circle they should be either brighter or darker than the central point + threshold
The speed is achieved by computing 4 points in the circle with 90 deg separation (top, bottom, left, right)
if 3 of such points are either brighter or darker than the central point then only it proceeds forward
if the condition fails then the central point is changed
Usage :
// vector of keypoints
std::vector<cv::KeyPoint> keypoints;
// Construction of the Fast feature detector object
cv::Ptr<cv::FeatureDetector> fast = FastFeatureDetector::create(30);
// feature point detection
fast->detect(Resize,keypoints);
// Draw Keypoints on the original image
cv::drawKeypoints(Resize, // original image
keypoints, // vector of keypoints
out, // the output image
cv::Scalar(255,255,255), // keypoint color (white)
cv::DrawMatchesFlags::DRAW_OVER_OUTIMG); //drawing flag
BRISK Feature Detector
Working :
It creates a pyramid of images by down scaling the input image by half each layer. In between these layers the image is again down scaled by 1.5
Then FAST feature extraction is applied to each image of the pyramid.
Then the key points are applied this criteria
- The key point must be local maximum comparing its strength with 8 spatial neighbors
- Then the key point is compared with neighboring points in the layers above and below if the score is higher in scale as well then it is accepted as an interest point.
Usage :
// vector of keypoints
std::vector<cv::KeyPoint> keypoints1;
// Construction of the Fast feature detector object
cv::Ptr<cv::BRISK> brisk = BRISK::create();
// feature point detection
brisk->detect(Resize,keypoints1);
cv::drawKeypoints(Resize, // original image
keypoints1, // vector of keypoints
out1, // the output image
cv::Scalar(255,255,255), // keypoint color
cv::DrawMatchesFlags::DRAW_OVER_OUTIMG); //drawing flag
Feature Descriptors
Feature Descriptors are methods which describe the location and neighborhood
of the feature in vectors or binary form
Typically the Detectors themselves come with built-in descriptors.
Few Descriptors are:
- SURF
- SIFT
These descriptors are very rich and contain floating point vectors of dimension 64 or 128, These are costly, Hence I did not study them.
There a new Descriptors called as binary descriptors Examples are
- ORB
- BRISK
Feature Matching
Feature Matching matching descriptors by calculating distance between the descriptors using different techniques.
Various Methods for Matching Descriptors are :
-
BruteForce-L1: This is used for float descriptors. It uses L1 distance and is efficient and fast.
-
BruteForce: This is used for float descriptors. It uses L2 distance and can be better than L1, but it needs more CPU usage.
-
BruteForce-SL2: This is used for float descriptors and avoids square root computation from L2, which requires high CPU usage.
-
BruteForce-Hamming: This is used for binary descriptors and calculates the Hamming distance between the compared descriptors.
-
BruteForce-Hamming(2): This is used for binary descriptors (2 bits version).
-
FlannBased: This is used for float descriptors and is faster than brute force at the cost of using more memory.
OpenCV encapsulates them all into one Function with various flags for different methods
Rejecting Matches
If we use simple Match then many key points get incorrectly matched. To reduce this we need to reject some matches
-
Cross-checking Matches Match using all key points of 1st image to 2nd image Repeat the match process with key points of 2nd image to the 1st image
-
Ratio Test Use knn to find the best 2 matches between the images
-
Distance Thresholding Reject Matches that have more distance between the vectors