Created
May 22, 2015 18:20
-
-
Save chrismedrdz/2c807488d339c7bd9935 to your computer and use it in GitHub Desktop.
Shape Detection Python+OpenCV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
im = cv2.imread('test.png') | |
imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) | |
ret,thresh = cv2.threshold(imgray,127,255,0) | |
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) | |
img = cv2.drawContours(im, contours, -1, (0,255,0), 3) | |
cv2.imshow('Contours',img) | |
cv2.waitKey() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment