Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/plusk01/opencv-gftt-score

Modified cv::goodFeaturesToTrack to return detection score
https://github.com/plusk01/opencv-gftt-score

feature-detection goodfeaturestotrack opencv robotics vio vision

Last synced: about 2 months ago
JSON representation

Modified cv::goodFeaturesToTrack to return detection score

Awesome Lists containing this project

README

        

OpenCV Good Features To Track with Scores
=========================================

This code returns a `std::vector` of detection scores from `cv::goodFeaturesToTrack`.

An interactive example is provided. The color changes between green (normalized score of 1.00) and red (normalized score of 0.00). Use `+`/`-` keys to choose the `n`-th greatest feature score to normalize by. Below is shown with `n=1`.



## Background

Under the hood, `cv::goodFeaturesToTrack` runs the following core code:

```c++
if( useHarrisDetector )
cornerHarris( image, eig, blockSize, gradientSize, harrisK );
else
cornerMinEigenVal( image, eig, blockSize, gradientSize );

double maxVal = 0;
minMaxLoc( eig, 0, &maxVal, 0, 0, _mask );
threshold( eig, eig, maxVal*qualityLevel, 0, THRESH_TOZERO );
dilate( eig, tmp, Mat());

// ...

std::sort( tmpCorners.begin(), tmpCorners.end(), greaterThanPtr() );
```

This code first calculates the minimum eigenvalue of the gradient each block (i.e., 3x3 neighborhood of image), as required for finding a [Shi-Tomasi / Harris corner](https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_shi_tomasi/py_shi_tomasi.html). If this minimum eigenvalue is above some threshold, then the pixel where the block was centered is considered as a feature. Note that the magnitude of an eigenvalue corresponds with how good of a feature that pixel is.

However, since a desired `qualityLevel` was requested, the next block of code thresholds every eigenvalue response below `maxVal*qualityLevel` to 0, where `maxVal` is the *greatest* minimum eigenvalue from the entire image.

Since there are only so many features that can be selected (`maxCorners`), the next code block then sorts the features by their associated eigenvalue response.