Book Image

OpenCV with Python By Example

By : Prateek Joshi
Book Image

OpenCV with Python By Example

By: Prateek Joshi

Overview of this book

Table of Contents (19 chapters)
OpenCV with Python By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Detecting the corners


Since we know that the corners are "interesting", let's see how we can detect them. In computer vision, there is a popular corner detection technique called Harris Corner Detector. We basically construct a 2x2 matrix based on partial derivatives of the grayscale image, and then analyze the eigenvalues. This is actually an oversimplification of the actual algorithm, but it covers the gist. So, if you want to understand the underlying mathematical details, you can look into the original paper by Harris and Stephens at http://www.bmva.org/bmvc/1988/avc-88-023.pdf. A corner point is a point where both the eigenvalues would have large values.

Let's consider the following image:

If you run the Harris corner detector on this image, you will see something like this:

As you can see, all the black dots correspond to the corners in the image. If you notice, the corners at the bottom of the box are not detected. The reason for this is that the corners are not sharp enough. You can...