forked from gautam678/CVIP-assistive-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep1.py
57 lines (41 loc) · 1.63 KB
/
step1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'''
Check if the coffeemaker is in the frame or not
Values will be read from Training files created prior to execution.
'''
######## Import Declarations ##########
import cv2
import numpy as np
import cPickle
#######################################
######## Objects Creation #############
cap = cv2.VideoCapture(0)
#######################################
'''
######## Reading the Files ############
minh =
maxh =
minm =
maxm =
#######################################
'''
######## Main Loop ####################
while True:
ret,im = cap.read() # Capture the frame
img = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) # Covert to grayscale
(thresh,imgg)=cv2.threshold(img,10,255,cv2.THRESH_BINARY | cv2.THRESH_OTSU) # Convert to Binary
ret,thresh = cv2.threshold(imgg,214,255,0) # Create contours
contours,hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
tmp = cPickle.dumps(contours)
contours = cPickle.loads(tmp)
img1=np.zeros((480,640,1),np.uint8) # IMG1 Blank Image
cv2.drawContours(img1,contours,-1,(255,255,255),3) # Draw the obtained contours
cv2.imshow("ALL CONTOURS", img1) # Displays All Contours
for C in contours:
for c in C:
print "##"
print c,
print "$$"
print "**"
if cv2.waitKey(10) == 27:
cv2.destroyAllWindows()
break