OpenCV Feature Detection and Description -- Shi-Tomasi Corner Detector

Original link: https://docs.opencv.org/4.1.2/d4/d8c/tutorial_py_shi_tomasi.html

If wrong welcome that - thank you


Goal

In this chapter,

  • We will learn about the another corner detector: Shi-Tomasi Corner Detector
  • We will see the function: cv.goodFeaturesToTrack()

aims:

In this section,

  • We will learn other corner detection: Shi-Tomasi Corner Detector
  • The learning function is:  cv.goodFeaturesToTrack ()

 

Theory

In last chapter, we saw Harris Corner Detector. Later in 1994, J. Shi and C. Tomasi made a small modification to it in their paper Good Features to Track which shows better results compared to Harris Corner Detector. The scoring function in Harris Corner Detector was given by:

theory:

In the last chapter, in late 1994, we saw Harris Corner Detector. J.Shi and C. Tomasi in their paper Good Good to Track Harris in view of the changes were small compared with the Harris Harris Detector, which showed better results. Harris scoring function is given by:

                                                                     

 

His replacement is Shi-Tomasi proposed:

                                                                   

 

If it is a greater than a threshold value, it is considered as a corner. If we plot it in λ1λ2 space as we did in Harris Corner Detector, we get an image as below:

If greater than the threshold value, it is regarded as the corner points. If, as it is drawn in a space λ1-λ2 Harris Corner Detector, the image will be obtained as follows:

                                                           

 

 

From the figure, you can see that only when λ1 and λ2 are above a minimum value, λmin, it is conidered as a corner(green region).

As it can be seen from the figure, only when λ1 and λ2 Amm above the minimum, it will be considered a corner (green).  

 

Code

OpenCV has a function, cv.goodFeaturesToTrack(). It finds N strongest corners in the image by Shi-Tomasi method (or Harris Corner Detection, if you specify it). As usual, image should be a grayscale image. Then you specify number of corners you want to find. Then you specify the quality level, which is a value between 0-1, which denotes the minimum quality of corner below which everyone is rejected. Then we provide the minimum euclidean distance between corners detected.

Code:

OpenCV has such a function,  cv.goodFeaturesToTrack () . He can strongly corner in the N images, this function uses the Shi-Tomasi's method (Harris, or, if you want it specialization). Typically, the image is a grayscale image should be. Then, to define the number of good looking corner point. You then specify the quality level, the value is the value between the range of 0-1, this value represents the quality of each corner point rejected the minimum angle. Then, we provide the minimum Euclidean distance between the detected angular.

 

With all this information, the function finds corners in the image. All corners below quality level are rejected. Then it sorts the remaining corners based on quality in the descending order. Then function takes first strongest corner, throws away all the nearby corners in the range of minimum distance and returns N strongest corners.

The use of all this information, this feature can be found in the image angle. All corner points below the level of quality were rejected. It then sorted in descending order according to the quality of the remaining corners. The function then first acquires the strongest corner, then drop all around the corners of a minimum distance range, and then returns the N strongest corner.

 

In below example, we will try to find 25 best corners:

In the following program, we will try to find 25 of the best corners:

 1 import numpy as np
 2 import cv2 as cv
 3 from matplotlib import pyplot as plt
 4 img = cv.imread('blox.jpg')
 5 gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
 6 corners = cv.goodFeaturesToTrack(gray,25,0.01,10)
 7 corners = np.int0(corners)
 8 for i in corners:
 9     x,y = i.ravel()
10     cv.circle(img,(x,y),3,255,-1)
11 plt.imshow(img),plt.show()
tomasi

See the result below:

result:

                        

 

 

 This function is more appropriate for tracking. We will see that when its time comes.

This feature is more suitable track. We will see that when its time comes.

I've tested the performance of the previous two algorithms, some of the key points are similar. But it seems more Tomasi speed a little faster.


 

 ** Note: ** complementary mathematical knowledge

Reference  https://blog.csdn.net/robert_chen1988/article/details/88576194 

* Matrix trace (trace)

    Main diagonal element of the matrix and

* Determinant (determinant)

    DET is a determinant of the matrix A (A) 

Guess you like

Origin www.cnblogs.com/mrAAron/p/11840972.html