Ditched '_find_SET()', since it was a no-value-added wrapper around
[python/dscho.git] / Demo / sgi / sv / burstcapt.py
blobce1e579f36563f54a11981cd476043ea0a40df9e
1 import sys
2 import sv, SV
3 import gl, GL, DEVICE
5 def main():
6 format = SV.RGB8_FRAMES
7 requestedwidth = SV.PAL_XMAX
8 queuesize = 30
9 if sys.argv[1:]:
10 queuesize = eval(sys.argv[1])
12 v = sv.OpenVideo()
13 svci = (format, requestedwidth, 0, queuesize, 0)
15 go = raw_input('Press return to capture ' + `queuesize` + ' frames: ')
16 result = v.CaptureBurst(svci)
17 svci, buffer, bitvec = result
18 ## svci, buffer = result # XXX If bit vector not yet implemented
20 print 'Captured', svci[3], 'frames, i.e.', len(buffer)/1024, 'K bytes'
22 w, h = svci[1:3]
23 framesize = w * h
25 gl.prefposition(300, 300+w-1, 100, 100+h-1)
26 gl.foreground()
27 win = gl.winopen('Burst Capture')
28 gl.RGBmode()
29 gl.gconfig()
30 gl.qdevice(DEVICE.LEFTMOUSE)
31 gl.qdevice(DEVICE.ESCKEY)
33 print 'Click left mouse for next frame'
35 for i in range(svci[3]):
36 inverted_frame = sv.RGB8toRGB32(1, \
37 buffer[i*framesize:(i+1)*framesize], w, h)
38 gl.lrectwrite(0, 0, w-1, h-1, inverted_frame)
39 while 1:
40 dev, val = gl.qread()
41 if dev == DEVICE.LEFTMOUSE and val == 1:
42 break
43 if dev == DEVICE.REDRAW:
44 gl.lrectwrite(0, 0, w-1, h-1, inverted_frame)
45 if dev == DEVICE.ESCKEY:
46 v.CloseVideo()
47 gl.winclose(win)
48 return
49 v.CloseVideo()
50 gl.winclose(win)
52 main()