-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvision.py
More file actions
26 lines (22 loc) · 707 Bytes
/
vision.py
File metadata and controls
26 lines (22 loc) · 707 Bytes
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
import cv2
import numpy as np
frame = cv2.imread('image1.jpg')
while(True):
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower_green = np.array([85,100,20])
upper_green = np.array([95,200,255])
mask = cv2.inRange(hsv, lower_green, upper_green)
res = cv2.bitwise_and(frame,frame,mask=mask)
#cv2.imshow('orig',frame)
cv2.imshow('fff',res)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
def onmouse(k,x,y,s,p):
global hsv
if k==1: # left mouse, print pixel at x,y
print hsv[y,x]
cv2.namedWindow("hsv")
cv2.setMouseCallback("hsv",onmouse);
cv2.imshow('hsv',hsv)
vid.release()
cv2.destroyAllWindows()