summaryrefslogtreecommitdiffstats
path: root/Demo/sgi/sv/burstcapt.py
blob: ce1e579f36563f54a11981cd476043ea0a40df9e (plain)
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
import sys
import sv, SV
import gl, GL, DEVICE

def main():
	format = SV.RGB8_FRAMES
	requestedwidth = SV.PAL_XMAX
	queuesize = 30
	if sys.argv[1:]:
		queuesize = eval(sys.argv[1])

	v = sv.OpenVideo()
	svci = (format, requestedwidth, 0, queuesize, 0)

	go = raw_input('Press return to capture ' + `queuesize` + ' frames: ')
	result = v.CaptureBurst(svci)
	svci, buffer, bitvec = result
##	svci, buffer = result # XXX If bit vector not yet implemented

	print 'Captured', svci[3], 'frames, i.e.', len(buffer)/1024, 'K bytes'

	w, h = svci[1:3]
	framesize = w * h

	gl.prefposition(300, 300+w-1, 100, 100+h-1)
	gl.foreground()
	win = gl.winopen('Burst Capture')
	gl.RGBmode()
	gl.gconfig()
	gl.qdevice(DEVICE.LEFTMOUSE)
	gl.qdevice(DEVICE.ESCKEY)

	print 'Click left mouse for next frame'

	for i in range(svci[3]):
		inverted_frame = sv.RGB8toRGB32(1, \
			  buffer[i*framesize:(i+1)*framesize], w, h)
		gl.lrectwrite(0, 0, w-1, h-1, inverted_frame)
		while 1:
			dev, val = gl.qread()
			if dev == DEVICE.LEFTMOUSE and val == 1:
				break
			if dev == DEVICE.REDRAW:
				gl.lrectwrite(0, 0, w-1, h-1, inverted_frame)
			if dev == DEVICE.ESCKEY:
				v.CloseVideo()
				gl.winclose(win)
				return
	v.CloseVideo()
	gl.winclose(win)

main()