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)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python | Corner detection with Harris Corner Detection method using OpenCV
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- OpenCV - Facial Landmarks and Face Detection using dlib and OpenCV
- Python | Detect corner of an image using OpenCV
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Detection of a specific color(blue here) using OpenCV with Python
- Face Detection using Python and OpenCV with webcam
- Python | Smile detection using OpenCV
- Circle Detection using OpenCV | Python
- White and black dot detection using OpenCV | Python
- Pedestrian Detection using OpenCV-Python
- Multiple Color Detection in Real-Time using Python-OpenCV
- Gun Detection using Python-OpenCV
- Contour Detection with Custom Seeds using Python - OpenCV
- Line detection in python with OpenCV | Houghline method
- Text Detection and Extraction using OpenCV and OCR
- OpenCV Python program for Vehicle detection in a Video frame
- Opencv Python program for Face Detection
- Transition from OpenCV 2 to OpenCV 3.x
- OpenCV C++ Program for coin detection
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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