Exemplo n.º 1
0
def test():
	import gl
	gl.foreground()
	gl.winopen('test watchcursor')
	defwatch(1)
	gl.setcursor(1, 0, 0)
	import time
	time.sleep(10)
Exemplo n.º 2
0
def test():
    import gl
    gl.foreground()
    gl.winopen('test watchcursor')
    defwatch(1)
    gl.setcursor(1, 0, 0)
    import time
    time.sleep(10)
Exemplo n.º 3
0
Arquivo: Vb.py Projeto: carol8421/gosh
	def makewindow(self):
		x, y = self.maxx, self.maxy
		gl.foreground()
		gl.maxsize(x, y)
		gl.keepaspect(x, y)
		gl.stepunit(8, 6)
		width = self.curx
		height = self.cury
		if width and height:
			# Place the window at (150, 150) from top left
			# (the video board likes this location...)
			x1 = 150
			x2 = x1+width-1
			SCRHEIGHT = 768
			y2 = SCRHEIGHT-1-150
			y1 = y2-height+1
			gl.prefposition(x1, x2, y1, y2)
		self.window = gl.winopen('Vb video')
		self.settitle()
		if width:
			gl.maxsize(x, y)
			gl.keepaspect(x, y)
			gl.stepunit(8, 6)
			gl.winconstraints()
		gl.qdevice(DEVICE.LEFTMOUSE)
		gl.qdevice(DEVICE.WINQUIT)
		gl.qdevice(DEVICE.WINSHUT)
Exemplo n.º 4
0
	def makewindow(self):
		x, y = self.maxx, self.maxy
		gl.foreground()
		gl.maxsize(x, y)
		gl.keepaspect(x, y)
		gl.stepunit(8, 6)
		width = self.curx
		height = self.cury
		if width and height:
			# Place the window at (150, 150) from top left
			# (the video board likes this location...)
			x1 = 150
			x2 = x1+width-1
			SCRHEIGHT = 768
			y2 = SCRHEIGHT-1-150
			y1 = y2-height+1
			gl.prefposition(x1, x2, y1, y2)
		self.window = gl.winopen('Vb video')
		self.settitle()
		if width:
			gl.maxsize(x, y)
			gl.keepaspect(x, y)
			gl.stepunit(8, 6)
			gl.winconstraints()
		gl.qdevice(DEVICE.LEFTMOUSE)
		gl.qdevice(DEVICE.WINQUIT)
		gl.qdevice(DEVICE.WINSHUT)
Exemplo n.º 5
0
def show(file):
    import gl, GL, DEVICE
    jpegdata = open(file, 'r').read()
    imgdata, width, height, bytesperpixel = decompress(jpegdata)
    gl.foreground()
    gl.prefsize(width, height)
    win = gl.winopen(file)
    if bytesperpixel == 1:
        gl.cmode()
        gl.pixmode(GL.PM_SIZE, 8)
        gl.gconfig()
        for i in range(256):
            gl.mapcolor(i, i, i, i)

    else:
        gl.RGBmode()
        gl.pixmode(GL.PM_SIZE, 32)
        gl.gconfig()
    gl.qdevice(DEVICE.REDRAW)
    gl.qdevice(DEVICE.ESCKEY)
    gl.qdevice(DEVICE.WINQUIT)
    gl.qdevice(DEVICE.WINSHUT)
    gl.lrectwrite(0, 0, width - 1, height - 1, imgdata)
    while 1:
        dev, val = gl.qread()
        if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
            break
        if dev == DEVICE.REDRAW:
            gl.lrectwrite(0, 0, width - 1, height - 1, imgdata)

    gl.winclose(win)
    newjpegdata = compress(imgdata, width, height, bytesperpixel)
    open('/tmp/j.jpg', 'w').write(newjpegdata)
Exemplo n.º 6
0
	def __init__(self, pktmax, vw, vh, type):
		self.pktmax = pktmax
		self.realwidth, self.realheight = vw, vh
		if type <> 'rgb':
			raise 'Incorrent video data type', type
		self.type = type
		self.width = vw
		self.height = vh
		#
		# Open dummy window
		#
		gl.foreground()
		gl.noport()
		self.wid = gl.winopen('DisplayVideoIn')
		
		self.x0 = 0
		self.x1 = self.x0 + self.width - 1
		self.y0 = 0
		self.y1 = self.y0 + self.height - 1
		# Compute # full lines per packet
		self.lpp = pktmax / self.linewidth()
		if self.lpp <= 0:
			raise 'No lines in packet', self.linewidth()
		self.pktsize = self.lpp*self.linewidth()
		self.data = None
		self.old_data = None
		self.dataoffset = 0
		self.lpos = 0
		self.hints = 0
Exemplo n.º 7
0
def show(file):
    import gl, GL, DEVICE
    jpegdata = open(file, 'r').read()
    imgdata, width, height, bytesperpixel = decompress(jpegdata)
    gl.foreground()
    gl.prefsize(width, height)
    win = gl.winopen(file)
    if bytesperpixel == 1:
        gl.cmode()
        gl.pixmode(GL.PM_SIZE, 8)
        gl.gconfig()
        for i in range(256):
            gl.mapcolor(i, i, i, i)

    else:
        gl.RGBmode()
        gl.pixmode(GL.PM_SIZE, 32)
        gl.gconfig()
    gl.qdevice(DEVICE.REDRAW)
    gl.qdevice(DEVICE.ESCKEY)
    gl.qdevice(DEVICE.WINQUIT)
    gl.qdevice(DEVICE.WINSHUT)
    gl.lrectwrite(0, 0, width - 1, height - 1, imgdata)
    while 1:
        dev, val = gl.qread()
        if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
            break
        if dev == DEVICE.REDRAW:
            gl.lrectwrite(0, 0, width - 1, height - 1, imgdata)

    gl.winclose(win)
    newjpegdata = compress(imgdata, width, height, bytesperpixel)
    open('/tmp/j.jpg', 'w').write(newjpegdata)
Exemplo n.º 8
0
def main():
    gl.foreground()
    gl.noport()
    #gl.prefposition(700, 850, 950, 970)
    wid = gl.winopen('audio demo')
    #
    panels = panel.defpanellist('apanel.s')  # XXX
    p = panels[0]
    p.playbackbutton.back = p
    p.recordbutton.back = p
    p.sample = ''

    #
    def quit(a):
        sys.exit(0)

    #
    p.quitbutton.downfunc = quit

    #
    def playback(a):
        p = a.back
        gain = int(255.0 * p.outputgain.val)
        a.val = 1.0
        a.fixact()
        panel.drawpanel()
        audio.setoutgain(gain)
        audio.write(p.sample)
        audio.setoutgain(0)
        a.val = 0.0
        a.fixact()

    #
    p.playbackbutton.downfunc = playback

    #
    def record(a):
        p = a.back
        size = int(10.0 * 8192.0 * p.recordsize.val)
        a.val = 1.0
        a.fixact()
        panel.drawpanel()
        audio.setoutgain(0)
        p.sample = audio.read(size)
        a.val = 0.0
        a.fixact()

    #
    p.recordbutton.downfunc = record
    #
    while 1:
        act = panel.dopanel()
Exemplo n.º 9
0
 def _init(self, title):
     self._docsize = (0, 0)
     self._fg = G.fg
     self._bg = G.bg
     self._title = title
     self._font = G.font
     self._size = G.size
     self._menus = []
     self._gid = gl.winopen(title)
     gl.winconstraints()  # To remove prefsize() effect
     self._fixviewport()
     self._needredraw()
     return self
Exemplo n.º 10
0
	def show(self):
		if self.wid < 0:
			gl.foreground()
			gl.prefsize(self.vin.width, self.vin.height)
			self.wid = gl.winopen(self.title)
			gl.clear()
			self.vin.initcolormap()
		gl.winset(self.wid)
		if self.qindex >= self.qsize:
			self.vin.clear()
			return
		dt, d, cd = self.vin.getrandomframe(self.qindex)
		self.vin.showframe(d, cd)
Exemplo n.º 11
0
 def show(self):
     if self.wid < 0:
         gl.foreground()
         gl.prefsize(self.vin.width, self.vin.height)
         self.wid = gl.winopen(self.title)
         gl.clear()
         self.vin.initcolormap()
     gl.winset(self.wid)
     if self.qindex >= self.qsize:
         self.vin.clear()
         return
     dt, d, cd = self.vin.getrandomframe(self.qindex)
     self.vin.showframe(d, cd)
Exemplo n.º 12
0
 def show(self):
     if self.wid < 0:
         gl.foreground()
         gl.prefsize(self.vout.width, self.vout.height)
         self.wid = gl.winopen(self.title)
         gl.clear()
         self.vout.initcolormap()
     gl.winset(self.wid)
     if not self.queue:
         self.vout.clear()
         return
     dt, d, cd = self.queue[-1]
     self.vout.showframe(d, cd)
Exemplo n.º 13
0
	def _init(self, title):
		self._docsize = (0, 0)
		self._fg = G.fg
		self._bg = G.bg
		self._title = title
		self._font = G.font
		self._size = G.size
		self._menus = []
		self._gid = gl.winopen(title)
		gl.winconstraints() # To remove prefsize() effect
		self._fixviewport()
		self._needredraw()
		return self
Exemplo n.º 14
0
	def show(self):
		if self.wid < 0:
			gl.foreground()
			gl.prefsize(self.vout.width, self.vout.height)
			self.wid = gl.winopen(self.title)
			gl.clear()
			self.vout.initcolormap()
		gl.winset(self.wid)
		if not self.queue:
			self.vout.clear()
			return
		dt, d, cd = self.queue[-1]
		self.vout.showframe(d, cd)
Exemplo n.º 15
0
def main():
    gl.foreground()
    gl.prefsize(SV.PAL_XMAX, SV.PAL_YMAX)
    win = gl.winopen('video test')
    v = sv.OpenVideo()
    params = [SV.VIDEO_MODE, SV.COMP, SV.BROADCAST, SV.PAL]
    v.SetParam(params)
    v.BindGLWindow(win, SV.IN_REPLACE)
    gl.qdevice(DEVICE.ESCKEY)
    gl.qdevice(DEVICE.WINQUIT)
    gl.qdevice(DEVICE.WINSHUT)
    while 1:
        dev, val = gl.qread()
        if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
            v.CloseVideo()
            gl.winclose(win)
            return
Exemplo n.º 16
0
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)
Exemplo n.º 17
0
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)
Exemplo n.º 18
0
def main():
	gl.foreground()
	gl.prefsize(SV.PAL_XMAX, SV.PAL_YMAX)
	win = gl.winopen('video test')
	v = sv.OpenVideo()
	params = [SV.VIDEO_MODE, SV.COMP, SV.BROADCAST, SV.PAL]
	v.SetParam(params)
	v.BindGLWindow(win, SV.IN_REPLACE)
	gl.qdevice(DEVICE.ESCKEY)
	gl.qdevice(DEVICE.WINQUIT)
	gl.qdevice(DEVICE.WINSHUT)
	while 1:
		dev, val = gl.qread()
		if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
			v.CloseVideo()
			gl.winclose(win)
			return
Exemplo n.º 19
0
Arquivo: gl.py Projeto: bpmnnit/codes
def main():
    gl.foreground()
    gl.prefposition(500, 900, 500, 900)
    w = gl.winopen('CrissCross')
    gl.ortho2(0.0, 400.0, 0.0, 400.0)
    gl.color(GL.WHITE)
    gl.clear()
    gl.color(GL.RED)
    gl.bgnline()
    gl.v2f(0.0, 0.0)
    gl.v2f(400.0, 400.0)
    gl.endline()
    gl.bgnline()
    gl.v2f(400.0, 0.0)
    gl.v2f(0.0, 400.0)
    gl.endline()
    time.sleep(5)
Exemplo n.º 20
0
Arquivo: gl.py Projeto: wasit7/cs428
def main():
    gl.foreground()
    gl.prefposition(500, 900, 500, 900)
    w = gl.winopen('CrissCross')
    gl.ortho2(0.0, 400.0, 0.0, 400.0)
    gl.color(GL.WHITE)
    gl.clear()
    gl.color(GL.RED)
    gl.bgnline()
    gl.v2f(0.0, 0.0)
    gl.v2f(400.0, 400.0)
    gl.endline()
    gl.bgnline()
    gl.v2f(400.0, 0.0)
    gl.v2f(0.0, 400.0)
    gl.endline()
    time.sleep(5)
Exemplo n.º 21
0
def gltest():
    import gl, fm
    gl.foreground()
    W, H = 1000, 800
    gl.prefsize(W, H)
    wid = gl.winopen('gltest')
    gl.ortho2(0, W, H, 0)
    gl.color(7)
    gl.clear()
    gl.color(0)
    fp = openfile()
    TSTART()
    fmt = GLFormatter().init(5, 0, W)
    feedfile(fp, fmt)
    fmt.flush()
    TSTOP()
    import time
    time.sleep(5)
Exemplo n.º 22
0
def test():
	import time
	if sys.argv[1:]: filename = sys.argv[1]
	else: filename = 'film.video'
	vin = VinFile(filename)
	vin.printinfo()
	gl.foreground()
	gl.prefsize(vin.getsize())
	wid = gl.winopen(filename)
	vin.initcolormap()
	t0 = time.time()
	while 1:
		try: t, data, cdata = vin.getnextframe()
		except EOFError: break
		dt = t0 + t - time.time()
		if dt > 0: time.time(dt)
		vin.showframe(data, cdata)
	time.sleep(2)
Exemplo n.º 23
0
def gltest():
	import gl, fm
	gl.foreground()
	W, H = 1000, 800
	gl.prefsize(W, H)
	wid = gl.winopen('gltest')
	gl.ortho2(0, W, H, 0)
	gl.color(7)
	gl.clear()
	gl.color(0)
	fp = openfile()
	TSTART()
	fmt = GLFormatter().init(5, 0, W)
	feedfile(fp, fmt)
	fmt.flush()
	TSTOP()
	import time
	time.sleep(5)
Exemplo n.º 24
0
def test():
    import time
    if sys.argv[1:]: filename = sys.argv[1]
    else: filename = 'film.video'
    vin = VinFile(filename)
    vin.printinfo()
    gl.foreground()
    gl.prefsize(vin.getsize())
    wid = gl.winopen(filename)
    vin.initcolormap()
    t0 = time.time()
    while 1:
        try:
            t, data, cdata = vin.getnextframe()
        except EOFError:
            break
        dt = t0 + t - time.time()
        if dt > 0: time.time(dt)
        vin.showframe(data, cdata)
    time.sleep(2)
Exemplo n.º 25
0
def imageview(file):
	import cl, CL, gl, GL, DEVICE

	filep = open(file, 'r')
	header = filep.read(16)
	filep.seek(0)
	scheme = cl.QueryScheme(header)
	decomp = cl.OpenDecompressor(scheme)
	headersize = cl.QueryMaxHeaderSize(scheme)
	header = filep.read(headersize)
	filep.seek(0)
	headersize = decomp.ReadHeader(header)
	width = decomp.GetParam(CL.IMAGE_WIDTH)
	height = decomp.GetParam(CL.IMAGE_HEIGHT)
	params = [CL.ORIGINAL_FORMAT, CL.RGBX, \
		  CL.ORIENTATION, CL.BOTTOM_UP, \
		  CL.FRAME_BUFFER_SIZE, width*height*CL.BytesPerPixel(CL.RGBX)]
	decomp.SetParams(params)

	image = decomp.Decompress(1, filep.read())
	filep.close()
	decomp.CloseDecompressor()

	gl.foreground()
	gl.prefsize(width, height)
	win = gl.winopen(file)
	gl.RGBmode()
	gl.pixmode(GL.PM_SIZE, 32)
	gl.gconfig()
	gl.qdevice(DEVICE.REDRAW)
	gl.qdevice(DEVICE.ESCKEY)
	gl.qdevice(DEVICE.WINQUIT)
	gl.qdevice(DEVICE.WINSHUT)
	gl.lrectwrite(0, 0, width-1, height-1, image)
	while 1:
		dev, val = gl.qread()
		if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
			break
		if dev == DEVICE.REDRAW:
			gl.lrectwrite(0, 0, width-1, height-1, image)
	gl.winclose(win)
Exemplo n.º 26
0
def testGL():
	import gl, GL, fmt
	if sys.argv[1:]: file = sys.argv[1]
	else: file = 'test.html'
	data = open(file, 'r').read()
	W, H = 600, 600
	gl.foreground()
	gl.prefsize(W, H)
	wid = gl.winopen('testGL')
	gl.ortho2(0, W, H, 0)
	gl.color(GL.WHITE)
	gl.clear()
	gl.color(GL.BLACK)
	b = fmt.GLBackEnd(wid)
	f = fmt.BaseFormatter(b.d, b)
	p = FormattingParser(f, GLStylesheet)
	p.feed(data)
	p.close()
	b.finish()
	#
	import time
	time.sleep(5)
Exemplo n.º 27
0
def testGL():
    import gl, GL, fmt
    if sys.argv[1:]: file = sys.argv[1]
    else: file = 'test.html'
    data = open(file, 'r').read()
    W, H = 600, 600
    gl.foreground()
    gl.prefsize(W, H)
    wid = gl.winopen('testGL')
    gl.ortho2(0, W, H, 0)
    gl.color(GL.WHITE)
    gl.clear()
    gl.color(GL.BLACK)
    b = fmt.GLBackEnd(wid)
    f = fmt.BaseFormatter(b.d, b)
    p = FormattingParser(f, GLStylesheet)
    p.feed(data)
    p.close()
    b.finish()
    #
    import time
    time.sleep(5)
Exemplo n.º 28
0
#! /usr/bin/env python
# Send live video UDP packets.
# Usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-w width]
#              [host] ..
import sys
import time
import struct
import string
from socket import *
from SOCKET import *
import gl, GL, DEVICE
sys.path.append('/ufs/guido/src/video')
import LiveVideoIn
import LiveVideoOut
import SV
import getopt
from IN import *
from senddefs import *

def usage(msg):
    print msg
    print 'usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-c type] [-m]',
    print '[-w width] [host] ...'
    print '-b        : broadcast on local net'
    print '-h height : window height (default ' + ` DEFHEIGHT ` + ')'
    print '-p port   : port to use (default ' + ` DEFPORT ` + ')'
    print '-t ttl    : time-to-live (multicast only; default 1)'
    print '-s size   : max packet size (default ' + ` DEFPKTMAX ` + ')'
    print '-w width  : window width (default ' + ` DEFWIDTH ` + ')'
    print '-c type   : Type: rgb8, mono or grey (default rgb8)'
Exemplo n.º 29
0
	if not sys.argv[1:]:
		print 'usage: www file'
		sys.exit(2)
	file = sys.argv[1]
	try:
		fp = open(file, 'r')
		data = fp.read()
		fp.close()
	except IOError, msg:
		print file, ':', msg
		sys.exit(1)

	W, H = 600, 600
	gl.foreground()
	gl.prefsize(W, H)
	wid = gl.winopen('glwww')
	gl.color(GL.WHITE)
	gl.clear()
	gl.ortho2(0, W, H, 0)
	gl.color(GL.BLACK)
	T.TSTART()
	fmt = GLFormatter().init(5, 0, W-5)
	p = html.FormattingParser().init(fmt, GLStylesheet)
	p.feed(data)
	p.close()
	T.TSTOP()
	gl.wintitle(p.title)
	import time
	time.sleep(5)

main()
Exemplo n.º 30
0
G.windowmap = {}  # Map window id to window object
G.windowmap['0'] = None  # For convenience
G.focus = None  # Input focus
G.fg = BLACK  # Foreground color
G.bg = WHITE  # Background color
G.def_size = 0, 0  # Default window size
G.def_pos = 0, 0  # Default window position
#
G.size = DEF_SIZE
G.font = fm.findfont(DEF_FONT).scalefont(G.size)

# Initialize GL
#
gl.foreground()
gl.noport()
dummygid = gl.winopen('')

# Ask for all sorts of events
#
# Both REDRAW (= resize and/or redraw!) and INPUTCHANGE are implicitly queued
#qdevice(REDRAW)
#qdevice(INPUTCHANGE)
#
# Keyboard
gl.qdevice(KEYBD)
gl.qdevice(LEFTARROWKEY)
gl.qdevice(RIGHTARROWKEY)
gl.qdevice(UPARROWKEY)
gl.qdevice(DOWNARROWKEY)
gl.qdevice(LEFTALTKEY)
gl.qdevice(RIGHTALTKEY)
Exemplo n.º 31
0
#! /usr/bin/env python
# Play synchronous video and audio.
# Highly experimental!
import sys
import getopt
import string
import os
import VFile
import aifc
import gl, GL, DEVICE
import al, AL

def usage():
	sys.stderr.write( \
		'usage: aplay [-o offset] [-q qsize] videofile audiofile\n')
	sys.exit(2)
def main():
	offset = 0
	qsize = 0 # This defaults to 1/10 second of sound
	videofile = 'film.video'
	audiofile = 'film.aiff'
	try:
		opts, args = getopt.getopt(sys.argv[1:], 'o:q:')
	except getopt.error, msg:
		sys.stderr.write(msg + '\n')
		usage()
	try:
		for o, a in opts:
			if o == '-o':
				offset = string.atoi(a)
Exemplo n.º 32
0
# Live video input from display class.
Exemplo n.º 33
0
import gl, GL
Exemplo n.º 34
0
    else:
        print 'Unknown video standard', param[1]
        sys.exit(1)

    gl.foreground()
    gl.maxsize(x, y)
    gl.keepaspect(x, y)
    gl.stepunit(8, 6)
    if width:
        height = width * 3 / 4
        x1 = 150
        x2 = x1 + width - 1
        y2 = 768 - 150
        y1 = y2 - height + 1
        gl.prefposition(x1, x2, y1, y2)
    win = gl.winopen(filename)
    if width:
        gl.maxsize(x, y)
        gl.keepaspect(x, y)
        gl.stepunit(8, 6)
        gl.winconstraints()
    x, y = gl.getsize()
    print x, 'x', y
    if memsize:
        number = calcnumber(x, y, grey or mono, memsize)
        print number, 'frames'
    v.SetSize(x, y)

    if drop:
        param = [SV.FIELDDROP, 1, SV.GENLOCK, SV.GENLOCK_OFF]
    else:
Exemplo n.º 35
0
#! /usr/bin/env python
#! /ufs/guido/bin/sgi/python-405
# Capture a CMIF movie using the Indigo video library and board
# The CMIF video file format is documented in cmif-film.ms.
# Audio data is recorded in AIFF format, using the input sampling
# rate, source and volume set by the audio panel, in mono, 8
# bits/sample.

# Usage and help functions (keep this up-to-date if you change the program!)
def usage():
	print 'Usage: Vrec [options] [moviefile [audiofile]]'
	print
	print 'Options:'
	print '-a            : record audio as well'
	print '-q queuesize  : set the capture queue size (default 2)'
	print '-r rate       : capture 1 out of every "rate" frames', \
	                     '(default and min 2)'
	print '-w width      : initial window width', \
                             '(default 256, use 0 for interactive placement)'
	print '-n            : Don\'t write to file, only timing info'
	print '-d            : drop fields if needed'
	print '-g bits       : greyscale (2, 4 or 8 bits)'
	print '-G            : 2-bit greyscale dithered'
	print '-m            : monochrome dithered'
	print '-M value      : monochrome thresholded with value'
	print '-f            : Capture fields (in stead of frames)'
	print '-P frames     : preallocate space for "frames" frames'
	print 'moviefile     : here goes the movie data (default film.video)'
	print 'audiofile     : with -a, here goes the audio data', \
		  	     '(default film.aiff)'
Exemplo n.º 36
0
#! /usr/bin/env python
Exemplo n.º 37
0
# Live video input from display class.
Exemplo n.º 38
0
                xpos = string.atoi(optarg)
            if opt == '-y':
                ypos = string.atoi(optarg)
    except string.atoi_error, msg:
        usage('bad integer: ' + msg)

    for host in args:
        hosts.append(gethostbyname(host))

    if not hosts:
        hosts.append(gethostbyname(DEFMCAST))

    gl.foreground()
    gl.prefsize(width, height)
    gl.stepunit(8, 6)
    wid = gl.winopen('Vsend')
    gl.keepaspect(width, height)
    gl.stepunit(8, 6)
    gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX)
    gl.winconstraints()
    gl.qdevice(DEVICE.ESCKEY)
    gl.qdevice(DEVICE.WINSHUT)
    gl.qdevice(DEVICE.WINQUIT)
    gl.qdevice(DEVICE.WINFREEZE)
    gl.qdevice(DEVICE.WINTHAW)
    width, height = gl.getsize()

    lvo = LiveVideoOut.LiveVideoOut(wid, width, height, vtype)

    lvi = DisplayVideoIn.DisplayVideoIn(pktmax, width, height, vtype)
Exemplo n.º 39
0
	try:
		for opt, optarg in opts:
			if opt == '-p':
				port = string.atoi(optarg)
			if opt == '-m':
				group = gethostbyname(optarg)
			if opt == '-c':
				vtype = optarg
	except string.atoi_error, msg:
		usage('bad integer: ' + msg)

	s = opensocket(group, port)

	gl.foreground()
	gl.prefsize(width, height)
	wid = gl.winopen('Vreceive')
	gl.winconstraints()
	gl.qdevice(DEVICE.ESCKEY)
	gl.qdevice(DEVICE.WINSHUT)
	gl.qdevice(DEVICE.WINQUIT)

	lvo = LiveVideoOut.LiveVideoOut(wid, width, height, vtype)

	ifdlist = [gl.qgetfd(), s.fileno()]
	ofdlist = []
	xfdlist = []
	timeout = 1.0
	selectargs = (ifdlist, ofdlist, xfdlist, timeout)

	while 1:
Exemplo n.º 40
0
#! /usr/bin/env python
# Play CMIF movie files
# Help function

def help():
    print 'Usage: Vplay [options] [file] ...'
    print
    print 'Options:'
    print '-M magnify : magnify the image by the given factor'
    print '-d         : write some debug stuff on stderr'
    print '-l         : loop, playing the movie over and over again'
    print '-m delta   : drop frames closer than delta seconds (default 0.)'
    print '-n         : don\'t wait after each file'
    print '-q         : quiet, no informative messages'
    print '-r delta   : regenerate input time base delta seconds apart'
    print '-s speed   : speed change factor (default 1.0)'
    print '-t         : use a 2nd thread for read-ahead'
    print '-x left    : window offset from left of screen'
    print '-y top     : window offset from top of screen'
    print '-w width   : window width'
    print '-h height  : window height'
    print '-b color   : background color (white,black or (r,g,b))'
    print 'file ...   : file(s) to play; default film.video'
    print
    print 'User interface:'
    print 'Press the left mouse button to stop or restart the movie.'
    print 'Press ESC or use the window manager Close or Quit command'
    print 'to close the window and play the next file (if any).'

# Imported modules
Exemplo n.º 41
0
#! /usr/bin/env python
# Play CMIF movie files

# Help function
def help():
	print 'Usage: Vplay [options] [file] ...'
	print
	print 'Options:'
	print '-M magnify : magnify the image by the given factor'
	print '-d         : write some debug stuff on stderr'
	print '-l         : loop, playing the movie over and over again'
	print '-m delta   : drop frames closer than delta seconds (default 0.)'
	print '-n         : don\'t wait after each file'
	print '-q         : quiet, no informative messages'
	print '-r delta   : regenerate input time base delta seconds apart'
	print '-s speed   : speed change factor (default 1.0)'
	print '-t         : use a 2nd thread for read-ahead'
	print '-x left    : window offset from left of screen'
	print '-y top     : window offset from top of screen'
	print '-w width   : window width'
	print '-h height  : window height'
	print '-b color   : background color (white,black or (r,g,b))'
	print 'file ...   : file(s) to play; default film.video'
	print
	print 'User interface:'
	print 'Press the left mouse button to stop or restart the movie.'
	print 'Press ESC or use the window manager Close or Quit command'
	print 'to close the window and play the next file (if any).'

# Imported modules
Exemplo n.º 42
0
    try:
        for opt, optarg in opts:
            if opt == '-p':
                port = string.atoi(optarg)
            if opt == '-m':
                group = gethostbyname(optarg)
            if opt == '-c':
                vtype = optarg
    except string.atoi_error, msg:
        usage('bad integer: ' + msg)

    s = opensocket(group, port)

    gl.foreground()
    gl.prefsize(width, height)
    wid = gl.winopen('Vreceive')
    gl.winconstraints()
    gl.qdevice(DEVICE.ESCKEY)
    gl.qdevice(DEVICE.WINSHUT)
    gl.qdevice(DEVICE.WINQUIT)

    lvo = LiveVideoOut.LiveVideoOut(wid, width, height, vtype)

    ifdlist = [gl.qgetfd(), s.fileno()]
    ofdlist = []
    xfdlist = []
    timeout = 1.0
    selectargs = (ifdlist, ofdlist, xfdlist, timeout)

    while 1:
Exemplo n.º 43
0
def main():
    # insure that we at least have an X display before continuing.
    import os
    try:
        display = os.environ['DISPLAY']
    except:
        # Raise ImportError because regrtest.py handles it specially.
        raise ImportError, "No $DISPLAY -- skipping gl test"

    # touch all the attributes of gl without doing anything
    if verbose:
        print 'Touching gl module attributes...'
    for attr in glattrs:
        if verbose:
            print 'touching: ', attr
        getattr(gl, attr)

    # create a small 'Crisscross' window
    if verbose:
        print 'Creating a small "CrissCross" window...'
        print 'foreground'
    gl.foreground()
    if verbose:
        print 'prefposition'
    gl.prefposition(500, 900, 500, 900)
    if verbose:
        print 'winopen "CrissCross"'
    w = gl.winopen('CrissCross')
    if verbose:
        print 'clear'
    gl.clear()
    if verbose:
        print 'ortho2'
    gl.ortho2(0.0, 400.0, 0.0, 400.0)
    if verbose:
        print 'color WHITE'
    gl.color(GL.WHITE)
    if verbose:
        print 'color RED'
    gl.color(GL.RED)
    if verbose:
        print 'bgnline'
    gl.bgnline()
    if verbose:
        print 'v2f'
    gl.v2f(0.0, 0.0)
    gl.v2f(400.0, 400.0)
    if verbose:
        print 'endline'
    gl.endline()
    if verbose:
        print 'bgnline'
    gl.bgnline()
    if verbose:
        print 'v2i'
    gl.v2i(400, 0)
    gl.v2i(0, 400)
    if verbose:
        print 'endline'
    gl.endline()
    if verbose:
        print 'Displaying window for 2 seconds...'
    time.sleep(2)
    if verbose:
        print 'winclose'
    gl.winclose(w)
Exemplo n.º 44
0
#! /usr/bin/env python
# Send live video UDP packets.
# Usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-w width]
#              [host] ..
import sys
import time
import struct
import string
import math
from socket import *
from SOCKET import *
import gl, GL, DEVICE
sys.path.append('/ufs/guido/src/video')
import DisplayVideoIn
import LiveVideoOut
import SV
import getopt
from IN import *
from senddefs import *
def usage(msg):
	print msg
	print 'usage: Vsend [-b] [-h height] [-p port] [-s size] [-t ttl] [-c type] [-m]',
	print '[-w width] [host] ...'
	print '-b        : broadcast on local net'
	print '-h height : window height (default ' + `DEFHEIGHT` + ')'
	print '-p port   : port to use (default ' + `DEFPORT` + ')'
	print '-t ttl    : time-to-live (multicast only; default 1)'
	print '-s size   : max packet size (default ' + `DEFPKTMAX` + ')'
	print '-S size   : use this packet size/window size'
	print '-w width  : window width (default ' + `DEFWIDTH` + ')'
Exemplo n.º 45
0
# Implement 'jpeg' interface using SGI's compression library
Exemplo n.º 46
0
	else:
		print 'Unknown video standard', param[1]
		sys.exit(1)

	gl.foreground()
	gl.maxsize(x, y)
	gl.keepaspect(x, y)
	gl.stepunit(8, 6)
	if width:
		height = width*3/4
		x1 = 150
		x2 = x1 + width-1
		y2 = 768-150
		y1 = y2-height+1
		gl.prefposition(x1, x2, y1, y2)
	win = gl.winopen(filename)
	if width:
		gl.maxsize(x, y)
		gl.keepaspect(x, y)
		gl.stepunit(8, 6)
		gl.winconstraints()
	x, y = gl.getsize()
	print x, 'x', y

	v.SetSize(x, y)

	if drop:
		param = [SV.FIELDDROP, 1, SV.GENLOCK, SV.GENLOCK_OFF]
	else:
		param = [SV.FIELDDROP, 0, SV.GENLOCK, SV.GENLOCK_ON]
	if mono or grey:
Exemplo n.º 47
0
import sys
Exemplo n.º 48
0
import sys
Exemplo n.º 49
0
import sys
Exemplo n.º 50
0
import gl, GL
Exemplo n.º 51
0
    if not sys.argv[1:]:
        print 'usage: www file'
        sys.exit(2)
    file = sys.argv[1]
    try:
        fp = open(file, 'r')
        data = fp.read()
        fp.close()
    except IOError, msg:
        print file, ':', msg
        sys.exit(1)

    W, H = 600, 600
    gl.foreground()
    gl.prefsize(W, H)
    wid = gl.winopen('glwww')
    gl.color(GL.WHITE)
    gl.clear()
    gl.ortho2(0, W, H, 0)
    gl.color(GL.BLACK)
    T.TSTART()
    fmt = GLFormatter().init(5, 0, W - 5)
    p = html.FormattingParser().init(fmt, GLStylesheet)
    p.feed(data)
    p.close()
    T.TSTOP()
    gl.wintitle(p.title)
    import time
    time.sleep(5)

Exemplo n.º 52
0
#! /usr/bin/env python
Exemplo n.º 53
0
		usage('bad integer: ' + msg)

	for host in args:
		hosts.append(gethostbyname(host))

	if not hosts:
		hosts.append(gethostbyname(DEFMCAST))

	if not LiveVideoIn.have_video:
		print 'Sorry, no video available (use python-405)'
		sys.exit(1)

	gl.foreground()
	gl.prefsize(width, height)
	gl.stepunit(8, 6)
	wid = gl.winopen('Vsend')
	gl.keepaspect(width, height)
	gl.stepunit(8, 6)
	gl.maxsize(SV.PAL_XMAX, SV.PAL_YMAX)
	gl.winconstraints()
	gl.qdevice(DEVICE.ESCKEY)
	gl.qdevice(DEVICE.WINSHUT)
	gl.qdevice(DEVICE.WINQUIT)
	gl.qdevice(DEVICE.WINFREEZE)
	gl.qdevice(DEVICE.WINTHAW)
	width, height = gl.getsize()

	lvo = LiveVideoOut.LiveVideoOut(wid, width, height, vtype)

	lvi = LiveVideoIn.LiveVideoIn(pktmax, width, height, vtype)
Exemplo n.º 54
0
def main():
    format = SV.RGB8_FRAMES
    rate = 1
    width = 0
    drop = 0
    mono = 0
    grey = 0
    greybits = 0
    monotreshold = -1
    fields = 0
    number = 60

    opts, args = getopt.getopt(sys.argv[1:], 'r:w:dg:mM:Gfn:')
    for opt, arg in opts:
        if opt == '-r':
            rate = string.atoi(arg)
            if rate < 2:
                sys.stderr.write('-r rate must be >= 2\n')
                sys.exit(2)
        elif opt == '-w':
            width = string.atoi(arg)
        elif opt == '-d':
            drop = 1
        elif opt == '-g':
            grey = 1
            greybits = string.atoi(arg)
            if not greybits in (2, 4, 8):
                print 'Only 2, 4 or 8 bit greyscale supported'
        elif opt == '-G':
            grey = 1
            greybits = -2
        elif opt == '-m':
            mono = 1
        elif opt == '-M':
            mono = 1
            monotreshold = string.atoi(arg)
        elif opt == '-f':
            fields = 1
        elif opt == '-n':
            number = string.atoi(arg)

    if args[2:]:
        sys.stderr.write('usage: Vrec [options] [file]\n')
        sys.exit(2)

    if args:
        filename = args[0]
    else:
        filename = 'film.video'

    v = sv.OpenVideo()
    # Determine maximum window size based on signal standard
    param = [SV.BROADCAST, 0]
    v.GetParam(param)
    if param[1] == SV.PAL:
        x = SV.PAL_XMAX
        y = SV.PAL_YMAX
    elif param[1] == SV.NTSC:
        x = SV.NTSC_XMAX
        y = SV.NTSC_YMAX
    else:
        print 'Unknown video standard', param[1]
        sys.exit(1)

    gl.foreground()
    gl.maxsize(x, y)
    gl.keepaspect(x, y)
    gl.stepunit(8, 6)
    if width:
        gl.prefsize(width, width * 3 / 4)
    win = gl.winopen(filename)
    if width:
        gl.maxsize(x, y)
        gl.keepaspect(x, y)
        gl.stepunit(8, 6)
        gl.winconstraints()
    x, y = gl.getsize()
    print x, 'x', y

    v.SetSize(x, y)

    if drop:
        param = [SV.FIELDDROP, 1, SV.GENLOCK, SV.GENLOCK_OFF]
    else:
        param = [SV.FIELDDROP, 0, SV.GENLOCK, SV.GENLOCK_ON]
    if mono or grey:
        param = param + [SV.COLOR, SV.MONO, SV.INPUT_BYPASS, 1]
    else:
        param = param + [SV.COLOR, SV.DEFAULT_COLOR, SV.INPUT_BYPASS, 0]
    v.SetParam(param)

    v.BindGLWindow(win, SV.IN_REPLACE)

    gl.qdevice(DEVICE.LEFTMOUSE)
    gl.qdevice(DEVICE.WINQUIT)
    gl.qdevice(DEVICE.WINSHUT)
    gl.qdevice(DEVICE.ESCKEY)

    print 'Press left mouse to start recording'

    while 1:
        dev, val = gl.qread()
        if dev == DEVICE.LEFTMOUSE:
            if val == 1:
                info = format, x, y, number, rate
                record(v, info, filename, mono, grey, \
                   greybits, monotreshold, fields)
        elif dev == DEVICE.REDRAW:
            # Window resize (or move)
            x, y = gl.getsize()
            print x, 'x', y
            v.SetSize(x, y)
            v.BindGLWindow(win, SV.IN_REPLACE)
        elif dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT):
            # Quit
            v.CloseVideo()
            gl.winclose(win)
            break
Exemplo n.º 55
0
import sys