Skip to content

Commit aad474b

Browse files
Object Detection By Contours
1 parent 871dd60 commit aad474b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
33.3 KB
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# objeect detection
2+
import cv2
3+
img=cv2.imread('detect_blob.png')
4+
cv2.imshow('Original colored',img)
5+
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
6+
cv2.imshow('Original Gray',gray)
7+
8+
9+
thresh=cv2.adaptiveThreshold(gray,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,115,1)
10+
cv2.imshow('Thresh',thresh)
11+
12+
_,contours,hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
13+
img2=img.copy()
14+
index=-1
15+
thickness=5
16+
color=(255,0,255)
17+
cv2.drawContours(img2,contours,index,color,thickness)
18+
cv2.imshow('Contours',img2)
19+
20+
cv2.waitKey(0)
21+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)