home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyos2bin.zip / Demo / sgi / sv / burstcapt.py next >
Text File  |  1992-12-14  |  1KB  |  53 lines

  1. import sys
  2. import sv, SV
  3. import gl, GL, DEVICE
  4.  
  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])
  11.  
  12.     v = sv.OpenVideo()
  13.     svci = (format, requestedwidth, 0, queuesize, 0)
  14.  
  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
  19.  
  20.     print 'Captured', svci[3], 'frames, i.e.', len(buffer)/1024, 'K bytes'
  21.  
  22.     w, h = svci[1:3]
  23.     framesize = w * h
  24.  
  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)
  32.  
  33.     print 'Click left mouse for next frame'
  34.  
  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)
  51.  
  52. main()
  53.