Skip to Content
OpenCV 3 Computer Vision with Python Cookbook
book

OpenCV 3 Computer Vision with Python Cookbook

by Aleksei Spizhevoi, Aleksandr Rybnikov
March 2018
Beginner to intermediate
306 pages
9h 54m
English
Packt Publishing
Content preview from OpenCV 3 Computer Vision with Python Cookbook

How to do it...

You need to complete the following steps:

  1. Import the necessary modules:
import cv2import numpy as np
  1. Load an image and find its corners with cv2.cornerHarris:
img = cv2.imread('../data/scenetext01.jpg', cv2.IMREAD_COLOR)corners = cv2.cornerHarris(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY), 2, 3, 0.04)
  1. Process and display the result:
corners = cv2.dilate(corners, None)show_img = np.copy(img)show_img[corners>0.01*corners.max()]=[0,0,255]corners = cv2.normalize(corners, None, 0, 255, cv2.NORM_MINMAX).astype(np.uint8)show_img = np.hstack((show_img, cv2.cvtColor(corners, cv2.COLOR_GRAY2BGR)))cv2.imshow('Harris corner detector', show_img)if cv2.waitKey(0) == 27:    cv2.destroyAllWindows()
  1. Create a FAST detector and apply it to the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning OpenCV 3 Computer Vision with Python (Update)

Learning OpenCV 3 Computer Vision with Python (Update)

Joe Minichino, Joseph Howse
OpenCV 4 with Python Blueprints - Second Edition

OpenCV 4 with Python Blueprints - Second Edition

Dr. Menua Gevorgyan, Michael Beyeler (USD), Arsen Mamikonyan, Michael Beyeler

Publisher Resources

ISBN: 9781788474443Supplemental Content