1 '''
2 This file provides a basic framework for a live demo. In this case the
3 demo is for face and eye detection.
4
5 Copyright David S. Bolme
6
7 Created on Jul 9, 2011
8
9 @author: bolme
10 '''
11 import pyvision as pv
12 import cv
13 from pyvision.face.CascadeDetector import CascadeDetector
14 from pyvision.face.FilterEyeLocator import FilterEyeLocator
15
17 if event in [cv.CV_EVENT_LBUTTONDOWN,cv.CV_EVENT_LBUTTONUP]:
18 print "Mouse Event:",event,x,y
19
20 if __name__ == '__main__':
21
22
23 webcam = pv.Webcam()
24
25
26 cd = CascadeDetector(min_size=(100,100))
27 el = FilterEyeLocator()
28
29
30 cv.NamedWindow("PyVision Live Demo")
31 cv.SetMouseCallback("PyVision Live Demo", mouseCallback)
32
33 while True:
34
35 frame = webcam.query()
36
37
38 rects = cd(frame)
39 eyes = el(frame,rects)
40
41
42 for rect,leye,reye in eyes:
43 frame.annotateThickRect(rect, 'green', width=3)
44 frame.annotatePoint(leye, color='green')
45 frame.annotatePoint(reye, color='green')
46
47
48 frame.annotateLabel(pv.Point(10,10), "Press 'q' to quit.")
49
50
51 key_press = frame.show("PyVision Live Demo")
52
53
54 if key_press == ord('q'):
55 break
56