What is a Corner?
A corner can be interpreted as the junction of two edges (where an edge is a sudden change in image brightness).
Shi-Tomasi Corner Detection –
Shi-Tomasi Corner Detection was published by J.Shi and C.Tomasi in their paper ‘Good Features to Track‘. Here the basic intuition is that corners can be detected by looking for significant change in all direction.
We consider a small window on the image then scan the whole image, looking for corners.
Shifting this small window in any direction would result in a large change in appearance, if that particular window happens to be located on a corner.
Flat regions will have no change in any direction.
If there’s an edge, then there will be no major change along the edge direction.
Mathematical Overview –
For a window(W) located at (X, Y) with pixel intensity I(X, Y), formula for Shi-Tomasi Corner Detection is –
f(X, Y) = Σ (I(Xk, Yk) - I(Xk + ΔX, Yk + ΔY))2 where (Xk, Yk) ϵ W
According to the formula:
If we’re scanning the image with a window just as we would with a kernel and we notice that there is an area where there’s a major change no matter in what direction we actually scan, then we have a good intuition that there’s probably a corner there.
Calculation of f(X, Y) will be really slow. Hence, we use Taylor expansion to simplify the scoring function, R.
R = min(λ1, λ2) where λ1, λ2 are eigenvalues of resultant matrix
goodFeaturesToTrack() function –
Syntax : cv2.goodFeaturesToTrack(gray_img, maxc, Q, minD)
gray_img – Grayscale image with integral values
maxc – Maximum number of corners we want(give negative value to get all the corners)
Q – Quality level parameter(preferred value=0.01)
maxD – Maximum distance(preferred value=10)
- Python | Corner detection with Harris Corner Detection method using OpenCV
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- Line detection in python with OpenCV | Houghline method
- Python | Detect corner of an image using OpenCV
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Circle Detection using OpenCV | Python
- Pedestrian Detection using OpenCV-Python
- Python | Smile detection using OpenCV
- Face Detection using Python and OpenCV with webcam
- White and black dot detection using OpenCV | Python
- Opencv Python program for Face Detection
- Detection of a specific color(blue here) using OpenCV with Python
- OpenCV Python program for Vehicle detection in a Video frame
- OpenCV C++ Program for Face Detection
- Text Detection and Extraction using OpenCV and OCR
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : hachiman_20