Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning OpenCV 4 Computer Vision with Python 3 - Third Edition

You're reading from  Learning OpenCV 4 Computer Vision with Python 3 - Third Edition

Product type Book
Published in Feb 2020
Publisher Packt
ISBN-13 9781789531619
Pages 372 pages
Edition 3rd Edition
Languages
Authors (2):
Joseph Howse Joseph Howse
Profile icon Joseph Howse
Joe Minichino Joe Minichino
Profile icon Joe Minichino
View More author details

Table of Contents (13) Chapters

Preface Setting Up OpenCV Handling Files, Cameras, and GUIs Processing Images with OpenCV Depth Estimation and Segmentation Detecting and Recognizing Faces Retrieving Images and Searching Using Image Descriptors Building Custom Object Detectors Tracking Objects Camera Models and Augmented Reality Introduction to Neural Networks with OpenCV Other Book You May Enjoy Appendix A: Bending Color Space with the Curves Filter

Detecting Harris corners

Let's start by finding corners using the Harris corner detection algorithm. We will do this by implementing an example. If you continue to study OpenCV beyond this book, you will find that chessboards are a common subject of analysis in computer vision, partly because a checkered pattern is suited to many types of feature detection, and partly because chess is a popular pastime, especially in Russia, where many of OpenCV's developers live.

Here is our sample image of a chessboard and chess pieces:

OpenCV has a handy function called cv2.cornerHarris, which detects corners in an image. We can see this function at work in the following basic example:

import cv2

img = cv2.imread('../images/chess_board.png')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
dst = cv2.cornerHarris(gray, 2, 23, 0.04)
img[dst > 0.01 * dst.max()] = [0, 0, 255]
cv2...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}