Untitled
user_9363972
python
2 years ago
603 B
4
Indexable
import cv2 import numpy as np img = cv2.imread("images/shape.jpg") imgGrayScale = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) imgBlur = cv2.GaussianBlur(imgGrayScale, (7, 7), 1) imgCanny = cv2.Canny(imgBlur, 50, 50) def getContours(img): contours, _ = cv2.findContours( img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) for cnt in contours: area = cv2.contourArea(cnt) print(area) cv2.drawContours(imgContour, cnt, -1, (255, 0, 0), 3) imgContour = img.copy() getContours(imgCanny) cv2.imshow("Original Picture", imgContour) cv2.waitKey(0)
Editor is loading...
Leave a Comment