-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhand.py
53 lines (40 loc) · 1.32 KB
/
hand.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
import cv2
import moneydetector as md
import time
import hist_utils
import numpy as np
import camera
import math
#HEY HEY Maybe we should look into tracking fingers holding the bill rather than the bill itself
#easier to measure velocity, can't really measure bend in the dollar
#plus, finger overlap on the dollar inhibits the ability to recognize the dollar contour
frames = []
frameCount = 0
maxFrames = 1
#this should be the camera
cap = cv2.VideoCapture(0)
trained_hand = False
pointing_threshold = 300
hand_hist = None
start_timer = 0
cv2.namedWindow('frame', cv2.WINDOW_NORMAL)
#while(False):
while(True):
ret, frameorig = cap.read() #read a frame
frameorig = cv2.flip(frameorig, 1)
if not trained_hand:
if cv2.waitKey(1) & 0xFF == ord('p'):
hand_hist = hist_utils.get_hist(frameorig)
trained_hand = True
frame2 = hist_utils.draw_rects(frameorig, horizontal=False)
cv2.imshow("frame", frame2)
else:
hist = hist_utils.hist_filter(frameorig, hand_hist)
loc = hist_utils.get_color_point(frameorig, hand_hist)
print loc
cv2.circle(hist, (int(loc[0]),int(loc[1])), 5, [0,0,255], -1)
cv2.imshow("frame", hist)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()