OpenCV: Contours : Getting Started
docs.opencv.org › master › d4Jan 08, 2013 · Let's see how to find contours of a binary image: import numpy as np import cv2 as cv im = cv.imread ( 'test.jpg') imgray = cv.cvtColor (im, cv.COLOR_BGR2GRAY) ret, thresh = cv.threshold (imgray, 127, 255, 0) contours, hierarchy = cv.findContours (thresh, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)