Skip to content

Commit dab1609

Browse files
Merge pull request akshitagupta15june#1 from shubhagupta21april/patch-1
Create Contoursdetect.py
2 parents dc3244e + a27cfa3 commit dab1609

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Contoursdetect.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import numpy as np
2+
import cv2
3+
img=cv2.imread("olympic.png")
4+
img_gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
5+
ret,thresh=cv2.threshold(img_gray,127,255,0)
6+
contours,heirarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
7+
print("Number of contours="+str(len(contours)))
8+
print(contours[0])
9+
cv2.drawContours(img,contours,-1,(0,255,0),3)
10+
cv2.imshow('image',img)
11+
cv2.imshow('image_gray',img_gray)
12+
cv2.waitKey(0)
13+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)