Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
OpenCV 3 Computer Vision with Python Cookbook

You're reading from  OpenCV 3 Computer Vision with Python Cookbook

Product type Book
Published in Mar 2018
Publisher Packt
ISBN-13 9781788474443
Pages 306 pages
Edition 1st Edition
Languages
Authors (2):
Aleksei Spizhevoi Aleksei Spizhevoi
Profile icon Aleksei Spizhevoi
Aleksandr Rybnikov Aleksandr Rybnikov
Profile icon Aleksandr Rybnikov
View More author details
Toc

Table of Contents (11) Chapters close

Preface 1. I/O and GUI 2. Matrices, Colors, and Filters 3. Contours and Segmentation 4. Object Detection and Machine Learning 5. Deep Learning 6. Linear Algebra 7. Detectors and Descriptors 8. Image and Video Processing 9. Multiple View Geometry 10. Other Books You May Enjoy

Checking whether a point is within a contour

In this recipe, we will discover a way of checking whether a point is inside of a contour, or if it belongs to the contour's border.

Getting ready

You need to have OpenCV 3.x installed, with Python API support.

How to do it...

  1. Import all of the necessary modules, open an image, and display it on the screen:
import cv2, random
import numpy as np
img = cv2.imread('bw.png', cv2.IMREAD_GRAYSCALE)
  1. Find the contours of the image and display them:
im2, contours, hierarchy = cv2.findContours(img, cv2.RETR_TREE, 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 €14.99/month. Cancel anytime}