summaryrefslogtreecommitdiffstats
path: root/Demo/sgi/sv/rgbgrab.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-09-03 17:01:36 (GMT)
committerGuido van Rossum <guido@python.org>1992-09-03 17:01:36 (GMT)
commitdb96c5a7d9e3b7f7d84e98fe95003b61d7be72f6 (patch)
treec0dbef730860c49992e036dd9df3e9a42697b200 /Demo/sgi/sv/rgbgrab.py
parent62f6bc8e55ef2d0e226b1c3ad7b9aca58407ab7a (diff)
downloadcpython-db96c5a7d9e3b7f7d84e98fe95003b61d7be72f6.zip
cpython-db96c5a7d9e3b7f7d84e98fe95003b61d7be72f6.tar.gz
cpython-db96c5a7d9e3b7f7d84e98fe95003b61d7be72f6.tar.bz2
Initial revision
Diffstat (limited to 'Demo/sgi/sv/rgbgrab.py')
-rwxr-xr-xDemo/sgi/sv/rgbgrab.py81
1 files changed, 81 insertions, 0 deletions
diff --git a/Demo/sgi/sv/rgbgrab.py b/Demo/sgi/sv/rgbgrab.py
new file mode 100755
index 0000000..8013a53
--- /dev/null
+++ b/Demo/sgi/sv/rgbgrab.py
@@ -0,0 +1,81 @@
+import sys
+import sv, SV
+import gl, GL, DEVICE
+import time
+
+def main():
+ v = sv.OpenVideo()
+ # Determine maximum window size based on signal standard
+ param = [SV.BROADCAST, 0]
+ v.GetParam(param)
+ if param[1] == SV.PAL:
+ width = SV.PAL_XMAX
+ height = SV.PAL_YMAX
+ elif param[1] == SV.NTSC:
+ width = SV.NTSC_XMAX
+ height = SV.NTSC_YMAX
+ else:
+ print 'Unknown video standard', param[1]
+ sys.exit(1)
+
+ # Initially all windows are half size
+ grabwidth, grabheight = width/2, height/2
+
+ # Open still window
+ gl.foreground()
+ gl.prefsize(grabwidth, grabheight)
+ still_win = gl.winopen('Grabbed frame')
+ gl.keepaspect(width, height)
+ gl.maxsize(width, height)
+ gl.winconstraints()
+ gl.RGBmode()
+ gl.gconfig()
+ gl.clear()
+ gl.pixmode(GL.PM_SIZE, 8)
+
+ # Open live window
+ gl.foreground()
+ gl.prefsize(grabwidth, grabheight)
+ live_win = gl.winopen('Live video')
+ gl.keepaspect(width, height)
+ gl.maxsize(width, height)
+ gl.winconstraints()
+
+ # Bind live video
+ v.SetSize(gl.getsize())
+ v.BindGLWindow(live_win, SV.IN_REPLACE)
+
+ print 'Use leftmouse to grab frame'
+
+ gl.qdevice(DEVICE.LEFTMOUSE)
+ gl.qdevice(DEVICE.WINQUIT)
+ gl.qdevice(DEVICE.WINSHUT)
+ gl.qdevice(DEVICE.ESCKEY)
+ frame = None
+ while 1:
+ dev, val = gl.qread()
+ if dev == DEVICE.LEFTMOUSE and val == 0:
+ w, h, fields = v.CaptureOneFrame(SV.RGB8_FRAMES, \
+ grabwidth, grabheight)
+ frame = sv.InterleaveFields(1, fields, w, h)
+ gl.winset(still_win)
+ gl.lrectwrite(0, 0, w - 1, h - 1, frame)
+ gl.winset(live_win)
+ if dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT):
+ v.CloseVideo()
+ gl.winclose(live_win)
+ gl.winclose(still_win)
+ break
+ if dev == DEVICE.REDRAW and val == still_win:
+ gl.winset(still_win)
+ gl.reshapeviewport()
+ gl.clear()
+ grabwidth, grabheight = gl.getsize()
+ if frame:
+ gl.lrectwrite(0, 0, w - 1, h - 1, frame)
+ gl.winset(live_win)
+ if dev == DEVICE.REDRAW and val == live_win:
+ v.SetSize(gl.getsize())
+ v.BindGLWindow(live_win, SV.IN_REPLACE)
+
+main()