Good features to track
The Harris Corner Detector performs well in many cases, but it misses out on a few things. Around six years after the original paper by Harris and Stephens, Shi and Tomasi came up with a better corner detector. You can read the original paper at http://www.ai.mit.edu/courses/6.891/handouts/shi94good.pdf. J. Shi and C.Tomasi used a different scoring function to improve the overall quality. Using this method, we can find the N strongest corners in the given image. This is very useful when we don't want to use every single corner to extract information from the image.
If you apply the Shi-Tomasi Corner Detector to the image shown earlier, you will see something like this:
The following is the code:
import cv2 import numpy as np img = cv2.imread('images/box.png') gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) corners = cv2.goodFeaturesToTrack(gray, maxCorners=7, qualityLevel=0.05, minDistance=25) corners = np.float32(corners) for item in corners: x, y = item[0...