Commit 16aac45f authored by Guido van Rossum's avatar Guido van Rossum

Remove the SGI demos. These were all ancient and nobody cared enough.

parent d679e099
......@@ -43,12 +43,6 @@ rpc A set of classes for building clients and servers for
scripts Some useful Python scripts that I put in my bin
directory. No optional built-in modules needed.
sgi Demos that only run on Silicon Graphics machines.
These require at least one of the optional built-in
modules that only make sense for the SGI, such as
'gl', 'al', and 'sv'. Split in subdirectories
per subject.
sockets Examples for the new built-in module 'socket'.
threads Demos that use the 'thread' module. (Currently these
......
Introduction.
A number of programs have been written which access the Silicon
Graphics CD-ROM player. These programs all use the interface defined
in readcd.py (see readcd.doc for documentation).
Specifying music stretches.
The programs that are capable of reading music CD's all use the same
syntax to describe which part of the CD is to be read. The syntax
closely corresponds to the available methods in readcd.py.
The music to be read is divided into stretches of music. Each stretch
must be specified as a separate argument on the command line. A
stretch can be a whole CD track, specified as a single number; or it
can be a start time and a end time. The start and end times must be
specified as a tuple, thus: ``(starttime, endtime)''. Don't forget to
quote the parenthesis to the shell. Both starttime and endtime can be
``None'', a simple number which refers to a CD track, or a tuple
consisting of either 3 or 4 elements. A starttime of ``None'' refers
to the start of the CD, an endtime of ``None'' refers to the end of
the CD. A tuple of 3 elements is an absolute time on the CD. The
three elements are (minutes, seconds, frames). A tuple of 4 elements
is a track-relative time. The four elements are (track, minutes,
seconds, frames).
When one stretch ends at the end of a track and the following stretch
starts at the next track, there is the option of either playing or not
playing the pause between the two tracks. When either the end time of
the first stretch or the start time of the second stretch is specified
using absolute or track-relative times, the pause will not be played.
When both times are specified as simple track numbers, the pause will
be played.
If no stretches are specified, the whole CD will be played.
The programs.
Currently, the following programs exist.
playcd [ stretch specification ]
Play (part of) a CD through the system loadspeaker or
headphone set.
cdaiff [ file [ stretch specification ] ]
Copy (part of) a CD to a file. The file will be written in
AIFF format. If no file is specified, cdaiff will write to
the file ``@'' in the current directory.
These are some programs to work with the SCSI CD-ROM player's audio
interface (see cdaudio(3) in IRIX 4.0 or higher; tested only on 4.0.2).
See also the SGI-specific standard module 'readcd', documented as
"readcd.lib" in the library.
cdwin.py A trivial window interface to play a CD over the CD
player's audio jack. More functionality is left as an
excersice to the reader. Needs module stdwin.
listcd.py List the table-of-contents of a CD (data CDs will
appear as a single track).
playcd.py Read audio data from the CD and play it over the
Indigo's built-in speker or audio jack. Needs module al.
sendcd.py Read audio data from the CD and send it as UDP packets
over the network (to recvcd.py).
recvcd.py Receive UDP packets containing CD audio data (from
sendcd.py) and play them over the Indigo's built-in
speaker or audio jack. Needs module al. (Doesn't
actually use module cd.)
cdaiff.py Dump CD audio to disk in AIFF format.
Note that to read *data* CD-ROMs you must open /dev/rdsk/dks0d4s7 or
some such special file...
import sys
import readcd
import aifc
import AL
import cd
Error = 'cdaiff.Error'
def writeaudio(a, type, data):
a.writeframesraw(data)
def main():
if len(sys.argv) > 1:
a = aifc.open(sys.argv[1], 'w')
else:
a = aifc.open('@', 'w')
a.setsampwidth(AL.SAMPLE_16)
a.setnchannels(AL.STEREO)
a.setframerate(AL.RATE_44100)
r = readcd.Readcd()
for arg in sys.argv[2:]:
x = eval(arg)
try:
if len(x) <> 2:
raise Error, 'bad argument'
r.appendstretch(x[0], x[1])
except TypeError:
r.appendtrack(x)
r.setcallback(cd.audio, writeaudio, a)
r.play()
a.close()
main()
# List track info from CD player.
import cd
def main():
c = cd.open()
info = []
while 1:
try:
info.append(c.gettrackinfo(len(info) + 1))
except RuntimeError:
break
for i in range(len(info)):
start, total = info[i]
print 'Track', zfill(i+1), triple(start), triple(total)
def triple((a, b, c)):
return zfill(a) + ':' + zfill(b) + ':' + zfill(c)
def zfill(n):
s = `n`
return '0' * (2 - len(s)) + s
main()
# Play CD audio on speaker or headphones.
callbacktypes = ['audio','pnum','index','ptime','atime','catalog','ident','control']
def playaudio(port, type, audio):
port.writesamps(audio)
def prtrack(cdinfo, type, pnum):
if cdinfo.track[pnum] <> '':
print 'playing "' + cdinfo.track[pnum] + '"'
else:
print callbacktypes[type]+': '+`pnum`
def callback(arg, type, data):
print callbacktypes[type]+': '+`data`
def tcallback(arg, type, data):
print callbacktypes[type]+': '+triple(data)
def triple((a, b, c)):
return zfill(a) + ':' + zfill(b) + ':' + zfill(c)
def zfill(n):
s = `n`
return '0' * (2 - len(s)) + s
def prtrackinfo(info):
for i in range(len(info)):
start, total = info[i]
print 'Track', zfill(i+1), triple(start), triple(total)
statedict = ['ERROR', 'NODISK', 'READY', 'PLAYING', 'PAUSED', 'STILL']
def prstatus(status):
state, track, curtime, abstime, totaltime, first, last, \
scsi_audio, cur_block, dummy = status
print 'Status:',
if 0 <= state < len(statedict):
print statedict[state]
else:
print state
print 'Track: ', track
print 'Time: ', triple(curtime)
print 'Abs: ', triple(abstime)
print 'Total: ', triple(totaltime)
print 'First: ', first
print 'Last: ', last
print 'SCSI: ', scsi_audio
print 'Block: ', cur_block
print 'Future:', dummy
def main():
import sys, readcd, al, AL, cd, cdplayer
verbose = 0
r = readcd.Readcd()
prstatus(r.getstatus())
prtrackinfo(r.gettrackinfo())
cdinfo = cdplayer.Cdplayer(r.gettrackinfo())
if cdinfo.title <> '':
print 'Title: "' + cdinfo.title + '"'
if cdinfo.artist <> '':
print 'Artist: ' + cdinfo.artist
for arg in sys.argv[1:]:
if arg == '-v':
verbose = 1
continue
x = eval(arg)
try:
l = len(x)
r.appendstretch(x[0], x[1])
except TypeError:
r.appendtrack(x)
try:
oldparams = [AL.OUTPUT_RATE, 0]
params = oldparams[:]
al.getparams(AL.DEFAULT_DEVICE, oldparams)
params[1] = AL.RATE_44100
al.setparams(AL.DEFAULT_DEVICE, params)
config = al.newconfig()
config.setwidth(AL.SAMPLE_16)
config.setchannels(AL.STEREO)
port = al.openport('CD Player', 'w', config)
for i in range(8):
r.setcallback(i, callback, None)
if verbose:
r.setcallback(cd.ptime, tcallback, None)
r.setcallback(cd.atime, tcallback, None)
else:
r.removecallback(cd.ptime)
r.removecallback(cd.atime)
r.setcallback(cd.pnum, prtrack, cdinfo)
r.setcallback(cd.audio, playaudio, port)
data = r.play()
except KeyboardInterrupt:
status = r.getstatus()
print 'Interrupted at '+triple(status[2])+' into track '+ \
`status[1]`+' (absolute time '+triple(status[3])+')'
al.setparams(AL.DEFAULT_DEVICE, oldparams)
main()
# Receive UDP packets from sendcd.py and play them on the speaker or
# audio jack.
import al, AL
from socket import *
from cd import DATASIZE
PORT = 50505 # Must match the port in sendcd.py
def main():
s = socket(AF_INET, SOCK_DGRAM)
s.bind('', PORT)
oldparams = [AL.OUTPUT_RATE, 0]
params = oldparams[:]
al.getparams(AL.DEFAULT_DEVICE, oldparams)
params[1] = AL.RATE_44100
try:
al.setparams(AL.DEFAULT_DEVICE, params)
config = al.newconfig()
config.setwidth(AL.SAMPLE_16)
config.setchannels(AL.STEREO)
port = al.openport('CD Player', 'w', config)
while 1:
data = s.recv(DATASIZE)
if not data:
print 'EOF'
break
port.writesamps(data)
except KeyboardInterrupt:
pass
al.setparams(AL.DEFAULT_DEVICE, oldparams)
main()
# Read CD audio data from the SCSI CD player and send it as UDP
# packets to "recvcd.py" on another host.
#
# Usage: python sendcd.py [options] host [track | minutes seconds [frames]]
#
# Options:
# "-l" list track info and quit.
# "-s" display status and quit.
#
# Arguments:
# host host to send the audio data to (required unless -l or -s).
# track track number where to start; alternatively,
# min sec [frames] absolute address where to start;
# default is continue at current point according to status.
import cd
import sys
from socket import *
import getopt
PORT = 50505 # Must match the port in readcd.py
def main():
try:
optlist, args = getopt.getopt(sys.argv[1:], 'ls')
except getopt.error, msg:
sys.stderr.write(msg + '\n')
sys.exit(2)
player = cd.open()
prstatus(player)
size = player.bestreadsize()
if optlist:
for opt, arg in optlist:
if opt == '-l':
prtrackinfo(player)
elif opt == '-s':
prstatus(player)
return
if not args:
sys.stderr.write('usage: ' + sys.argv[0] + ' host [track]\n')
sys.exit(2)
host, args = args[0], args[1:]
sys.stdout.write('waiting for socket... ')
sys.stdout.flush()
port = socket(AF_INET, SOCK_DGRAM)
port.connect(host, PORT)
print 'socket connected'
parser = cd.createparser()
parser.setcallback(cd.audio, audiocallback, port)
parser.setcallback(cd.pnum, pnumcallback, player)
parser.setcallback(cd.index, indexcallback, None)
## cd.ptime: too many calls
## cd.atime: too many calls
parser.setcallback(cd.catalog, catalogcallback, None)
parser.setcallback(cd.ident, identcallback, None)
parser.setcallback(cd.control, controlcallback, None)
if len(args) >= 2:
if len(args) >= 3:
[min, sec, frame] = args[:3]
else:
[min, sec] = args
frame = '0'
min, sec, frame = eval(min), eval(sec), eval(frame)
print 'Seek to', triple(min, sec, frame)
dummy = player.seek(min, sec, frame)
elif len(args) == 1:
track = eval(args[0])
print 'Seek to track', track
dummy = player.seektrack(track)
else:
min, sec, frame = player.getstatus()[3]
print 'Try to seek back to', triple(min, sec, frame)
try:
player.seek(min, sec, frame)
except RuntimeError:
print 'Seek failed'
try:
while 1:
frames = player.readda(size)
if frames == '':
print 'END OF CD'
break
parser.parseframe(frames)
except KeyboardInterrupt:
print '[Interrupted]'
pass
def prtrackinfo(player):
info = []
while 1:
try:
info.append(player.gettrackinfo(len(info) + 1))
except RuntimeError:
break
for i in range(len(info)):
start, total = info[i]
print 'Track', zfill(i+1), triple(start), triple(total)
def audiocallback(port, type, data):
## sys.stdout.write('#')
## sys.stdout.flush()
port.send(data)
def pnumcallback(player, type, data):
print 'pnum =', `data`
prstatus(player)
def indexcallback(arg, type, data):
print 'index =', `data`
def catalogcallback(arg, type, data):
print 'catalog =', `data`
def identcallback(arg, type, data):
print 'ident =', `data`
def controlcallback(arg, type, data):
print 'control =', `data`
statedict = ['ERROR', 'NODISK', 'READY', 'PLAYING', 'PAUSED', 'STILL']
def prstatus(player):
state, track, curtime, abstime, totaltime, first, last, \
scsi_audio, cur_block, dummy = player.getstatus()
print 'Status:',
if 0 <= state < len(statedict):
print statedict[state]
else:
print state
print 'Track: ', track
print 'Time: ', triple(curtime)
print 'Abs: ', triple(abstime)
print 'Total: ', triple(totaltime)
print 'First: ', first
print 'Last: ', last
print 'SCSI: ', scsi_audio
print 'Block: ', cur_block
print 'Future:', dummy
def triple((a, b, c)):
return zfill(a) + ':' + zfill(b) + ':' + zfill(c)
def zfill(n):
s = `n`
return '0' * (2 - len(s)) + s
main()
tcache.fdc test_cb.fdc test_nocb.fdc
Magic: 12321
Internal Form Definition File
(do not change)
Number of forms: 2
=============== FORM ===============
Name: first
Width: 340.000000
Height: 160.000000
Number of Objects: 1
--------------------
class: 1
type: 1
box: 0.000000 0.000000 340.000000 160.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 10.000000
lcol: 0
label:
name:
callback:
argument:
=============== FORM ===============
Name: second
Width: 150.000000
Height: 400.000000
Number of Objects: 1
--------------------
class: 1
type: 1
box: 0.000000 0.000000 150.000000 400.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 10.000000
lcol: 0
label:
name:
callback:
argument:
==============================
create_the_forms
# Test bug in caching of forms
import sys
import os
import flp
filename = 'tcache.fd'
cachename = filename + 's'
def first():
try:
os.unlink(cachename)
except os.error:
pass
first = flp.parse_form(filename, 'first')
def second():
forms = flp.parse_forms(filename)
k = forms.keys()
if 'first' in k and 'second' in k:
print 'OK'
else:
print 'BAD!', k
def main():
if sys.argv[1:]:
second()
else:
first()
print 'Now run the script again with an argument'
main()
Magic: 12321
Internal Form Definition File
(do not change)
Number of forms: 1
=============== FORM ===============
Name: main_form
Width: 170.000000
Height: 190.000000
Number of Objects: 4
--------------------
class: 1
type: 1
box: 0.000000 0.000000 170.000000 190.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name:
callback:
argument:
--------------------
class: 11
type: 0
box: 10.000000 140.000000 150.000000 40.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: Button 1
name: button1
callback: button1CB
argument: 0
--------------------
class: 11
type: 0
box: 10.000000 100.000000 150.000000 40.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: Button 2
name: button2
callback: button2CB
argument: 0
--------------------
class: 11
type: 6
box: 10.000000 10.000000 150.000000 40.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: EXIT
name: exitbutton
callback: exitbuttonCB
argument: 0
==============================
create_the_forms
#
# Example 2 - Using fl in python with callbacks.
#
# The form is named 'main_form' and resides on file 'test_cb.fd'.
# It has three objects named button1, button2 and exitbutton.
# All buttons have callbacks with the same names as their corresponding
# buttons but with CB appended.
#
import fl # The forms library
import FL # Symbolic constants for the above
import flp # The module to parse .fd files
import sys
# The following struct is created to hold the instance variables
# main_form, button1, button2 and exitbutton.
class myform:
#
# The constructor parses and creates the form, but doesn't
# display it (yet).
def __init__(self, number):
#
# First we parse the form
parsetree = flp.parse_form('test_cb', 'main_form')
#
# Next we create it
flp.create_full_form(self, parsetree)
# And keep our number
self.number = number
#
# The show function displays the form. It doesn't do any interaction,
# though.
def show(self):
self.main_form.show_form(FL.PLACE_SIZE, 1, '')
# The callback functions
def button1CB(self, obj, arg):
print 'Button 1 pressed on form', self.number
def button2CB(self, obj, arg):
print 'Button 2 pressed on form', self.number
def exitbuttonCB(self, obj, arg):
print 'Ok, bye bye'
sys.exit(0)
#
# The main program. Instantiate two variables of the forms class
# and interact with them.
form1 = myform(1)
form2 = myform(2)
form1.show()
form2.show()
obj = fl.do_forms()
print 'do_forms() returned. This should not happen. obj=', obj
Magic: 12321
Internal Form Definition File
(do not change)
Number of forms: 1
=============== FORM ===============
Name: main_form
Width: 170.000000
Height: 190.000000
Number of Objects: 4
--------------------
class: 1
type: 1
box: 0.000000 0.000000 170.000000 190.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name:
callback:
argument:
--------------------
class: 11
type: 0
box: 10.000000 140.000000 150.000000 40.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: Button 1
name: button1
callback:
argument:
--------------------
class: 11
type: 0
box: 10.000000 100.000000 150.000000 40.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: Button 2
name: button2
callback:
argument:
--------------------
class: 11
type: 6
box: 10.000000 10.000000 150.000000 40.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: EXIT
name: exitbutton
callback:
argument:
==============================
create_the_forms
#
# Example 1 - Using fl in python without callbacks.
#
# The form is named 'main_form' and resides on file 'test_nocb.fd'.
# It has three objects named button1, button2 and exitbutton.
#
import fl # The forms library
import FL # Symbolic constants for the above
import flp # The module to parse .fd files
import sys
# The following struct is created to hold the instance variables
# main_form, button1, button2 and exitbutton.
class struct: pass
container = struct()
#
# We now first parse the forms file
parsetree = flp.parse_form('test_nocb', 'main_form')
#
# Next we create it
flp.create_full_form(container, parsetree)
#
# And display it
container.main_form.show_form(FL.PLACE_MOUSE, 1, '')
#
# And interact until the exit button is pressed
while 1:
selected_obj = fl.do_forms()
if selected_obj == container.button1:
print 'Button 1 selected'
elif selected_obj == container.button2:
print 'Button 2 selected'
elif selected_obj == container.exitbutton:
print 'Ok, bye bye'
sys.exit(0)
else:
print 'do_forms() returned unknown object ', selected_obj
These demos run only on SGI machines and require the 'gl' built-in module.
The demonstrate the abilities of SGI's GL library as well as the ease of
GL programming in Python. Most demos require the Z-buffer (aka
24-bitplane) option. Press ESC to get out of any of them.
backface.py Demonstrates the 'backface' GL function.
kites.py Show 3 flying kites. Demonstrates the rendering speed
obtainable by Python programs.
kunst.py Cute demo showing a ball suspended on four cables in
the central room of the CWI building. You can specify
three functions Fx(t), Fy(t), Fz(t) which define the
movement of the ball. Try something like sin(t),
cos(t), sin(2*t).
mclock.py A colorful clock with more options than you can
remember. Works on 8-bit machines, but allows more
colors on 24-bit machines. See mclock.doc for more
info.
mixing.py Demonstrates the effect of color mixing: through
frequent color switching it gives the effect of white
light.
nurbs.py A simple demonstration of the 'nurbs' GL functions.
Press left mouse button to toggle surface trimming.
zrgb.py Displays a 3-D Gouraud-shaded figure which can be moved
around with the mouse.
glstdwin/ This is quite different: a partial STDWIN emulation
using GL! Requires only small changes to Python
programs that use STDWIN. Some features not yet
implemented, e.g., scroll bars.
#! /usr/bin/env python
# backface
#
# draw a cube that can run with backface() turned on or off.
# cube is moved when LEFTMOUSE is pressed and mouse itself is moved.
from gl import *
from DEVICE import *
from GL import *
CUBE_SIZE = 200.0
CUBE_OBJ = 1
def main () :
#
x = 0
y = 0
moveit = 0
#
initialize()
#
while (1) :
#
while (qtest()) :
dev, val = qread()
#
if dev == ESCKEY :
backface(0)
return
#
elif dev == REDRAW :
reshapeviewport()
drawcube(x,y)
#
elif dev == LEFTMOUSE :
#
# LEFTMOUSE down
moveit = val
#
elif dev == BKEY :
backface(1)
drawcube(x,y)
#
elif dev == FKEY :
backface(0)
drawcube(x,y)
#
if moveit :
x = getvaluator(MOUSEX)
y = getvaluator(MOUSEY)
drawcube(x,y)
def initialize () :
foreground ()
keepaspect (1, 1)
gid = winopen('backface')
winset(gid)
winconstraints()
#
doublebuffer()
gconfig()
shademodel(FLAT)
#
ortho(-1024.0, 1024.0, -1024.0, 1024.0, -1024.0, 1024.0)
#
qdevice(ESCKEY)
qdevice(REDRAW)
qdevice(LEFTMOUSE)
qdevice(BKEY)
qdevice(FKEY)
qenter(REDRAW,gid)
#
backface(1)
#
# define a cube
def cube () :
#
# front face
pushmatrix()
translate(0.0,0.0,CUBE_SIZE)
color(RED)
rectf(-CUBE_SIZE,-CUBE_SIZE,CUBE_SIZE,CUBE_SIZE)
popmatrix()
#
# right face
pushmatrix()
translate(CUBE_SIZE, 0.0, 0.0)
rotate(900, 'y')
color(GREEN)
rectf(-CUBE_SIZE,-CUBE_SIZE,CUBE_SIZE,CUBE_SIZE)
popmatrix()
#
# back face
pushmatrix()
translate(0.0, 0.0, -CUBE_SIZE)
rotate(1800, 'y')
color(BLUE)
rectf(-CUBE_SIZE,-CUBE_SIZE,CUBE_SIZE,CUBE_SIZE)
popmatrix()
#
# left face
pushmatrix()
translate(-CUBE_SIZE, 0.0, 0.0)
rotate(-900, 'y')
color(CYAN)
rectf(-CUBE_SIZE,-CUBE_SIZE,CUBE_SIZE,CUBE_SIZE)
popmatrix()
#
# top face
pushmatrix()
translate(0.0, CUBE_SIZE, 0.0)
rotate(-900, 'x')
color(MAGENTA)
rectf(-CUBE_SIZE,-CUBE_SIZE,CUBE_SIZE,CUBE_SIZE)
popmatrix()
#
# bottom face
pushmatrix()
translate(0.0, -CUBE_SIZE, 0.0)
rotate(900, 'x')
color(YELLOW)
rectf(-CUBE_SIZE,-CUBE_SIZE,CUBE_SIZE,CUBE_SIZE)
popmatrix()
def drawcube(x,y) :
#
pushmatrix()
rotate(2*x, 'x')
rotate(2*y, 'y')
color(BLACK)
clear()
cube()
popmatrix()
swapbuffers()
main ()
#! /usr/bin/env python
# Print the values of all values that can be inquired with getgdesc().
# See man getgdesc() for a description.
import gl
import GL
def main():
names = []
maxlen = 0
for name in dir(GL):
if name[:3] == 'GD_':
names.append(name)
maxlen = max(maxlen, len(name))
for name in names:
print name + (maxlen - len(name))*' ' + '=',
print gl.getgdesc(getattr(GL, name))
main()
#! /usr/bin/env python
# *** This only works correctly on a 24 bit-plane machine. ***
#
# A simple Python program that tests the some parts of the
# GL library. It shows the speed that can be obtained when
# doing simple graphics.
#
# The bottleneck in this program is NOT Python but the graphics
# engine; i.e Python can feed the graphics pipeline fast enough
# on the 4D/25G.
#
# This program show 3 kites flying around the screen. It uses
#
# * bgnpolygon, endpolygon
# * v3, n3
# * lmdef, lmbind
#
# Usage :
#
# ESC -> exit program
# MOUSE3 -> freeze toggle
# MOUSE2 -> one step (use this in freeze state)
from GL import *
from gl import *
import DEVICE
from math import *
#
# viewobj : sets the rotation, translation and scaling
# set appropiate material, call drawobject()
#
def viewobj (r, s, t, mat) :
pushmatrix()
rot (r * 10.0, 'X')
rot (r * 10.0, 'Y')
rot (r * 10.0, 'Z')
scale (s[0], s[1], s[2])
translate (t[0], t[1], t[2])
lmbind(MATERIAL, mat)
drawobject()
popmatrix()
#
# makeobj : the constructor of the object
#
def mkobj () :
v0 = (-5.0 ,0.0, 0.0)
v1 = (0.0 ,5.0, 0.0)
v2 = (5.0 ,0.0, 0.0)
v3 = (0.0 ,2.0, 0.0)
n0 = (sqrt(2.0)/2.0, sqrt(2.0)/2.0, 0.0)
vn = ((v0, n0), (v1, n0), (v2, n0), (v3, n0))
#
return vn
#
# the object itself as an array of vertices and normals
#
kite = mkobj ()
#
# drawobject : draw a triangle. with bgnpolygon
#
def drawobject () :
#
bgnpolygon()
vnarray (kite)
endpolygon()
#
# identity matrix
#
idmat=[1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0]
#
# the rgb-value of light-blue
#
LightBlue = (43,169,255)
#
# the different materials.
#
m1=[SPECULAR,0.0,0.0,0.6,DIFFUSE,0.0,0.0,0.8,SHININESS,20.0,LMNULL]
m2=[SPECULAR,0.8,0.0,0.1,DIFFUSE,0.8,0.0,0.3,SHININESS,120.0,LMNULL]
m3=[SPECULAR,0.0,1.0,0.0,DIFFUSE,0.0,0.6,0.0,SHININESS,120.0,LMNULL]
#
# lightsources
#
light1 = [LCOLOR,1.0,1.0,1.0,POSITION,15.0,15.0,0.0,1.0,LMNULL]
light2 = [LCOLOR,1.0,1.0,1.0,POSITION,-15.0,15.0,0.0,1.0,LMNULL]
#
# the lightmodel
#
model = [AMBIENT,0.2,0.2,0.2,LMNULL]
#
# initgl : opens the window, configures the pipeline to 2buf and zbuf,
# sets the viewing, defines and binds the materials
#
def initgl () :
#
# open window
#
foreground ()
keepaspect (1, 1)
prefposition (100, 500, 100, 500)
w = winopen ('PYTHON lights')
keepaspect (1, 1)
winconstraints()
#
# configure pipeline (zbuf, 2buf, GOURAUD and RGBmode)
#
zbuffer (1)
doublebuffer ()
shademodel (GOURAUD)
RGBmode ()
gconfig ()
#
# define and bind materials (set perspective BEFORE loadmat !)
#
mmode(MVIEWING)
perspective (900, 1.0, 1.0, 20.0)
loadmatrix(idmat)
lmdef(DEFMATERIAL, 1, m1)
lmdef(DEFMATERIAL, 2, m2)
lmdef(DEFMATERIAL, 3, m3)
lmdef(DEFLIGHT, 1, light1)
lmdef(DEFLIGHT, 2, light2)
lmdef(DEFLMODEL, 1, model)
lmbind(LIGHT0,1)
lmbind(LIGHT1,2)
lmbind(LMODEL,1)
#
# set viewing
#
lookat (0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0)
#
# ask for the REDRAW and ESCKEY events
#
qdevice(DEVICE.MOUSE3)
qdevice(DEVICE.MOUSE2)
qdevice(DEVICE.REDRAW)
qdevice(DEVICE.ESCKEY)
#
# GoForIT : use 2buf to redraw the object 2n times. index i is used as
# the (smoothly changing) rotation angle
#
def GoForIt(i) :
freeze = 1
while 1 :
if freeze <> 0 :
i = i + 1
#
# clear z-buffer and clear background to light-blue
#
zclear()
c3i (LightBlue)
clear()
#
# draw the 3 traiangles scaled above each other.
#
viewobj(float(i),[1.0,1.0,1.0],[1.0,1.0,1.0],1)
viewobj(float(i),[0.75,0.75,0.75],[0.0,2.0,2.0],2)
viewobj(float(i),[0.5,0.5,0.5],[0.0,4.0,4.0],3)
#
swapbuffers()
#
if qtest() <> 0 :
dev, val = qread()
if dev == DEVICE.ESCKEY :
break
elif dev == DEVICE.REDRAW :
reshapeviewport ()
elif dev == DEVICE.MOUSE3 and val <> 0 :
freeze = 1 - freeze
elif dev == DEVICE.MOUSE2 and val <> 0 :
i = i + 1
# the main program
#
def main () :
initgl ()
GoForIt (0)
#
# exec main
#
main ()
This diff is collapsed.
Newsgroups: cwi.sgi
Subject: Re: new clock
Distribution: cwi.sgi
References: <2246@charon.cwi.nl>
Last week I wrote:
>For your enjoyment I have implemented a colorful clock.
The clock has now been extended with some new facilities: a menu, an
alarm and a gong. These may require some explanation beyond what's in
the usage message.
Menu
----
The right mouse button now pops up a menu that allows you to turn the
seconds hand on or off and to switch the alarm off.
Alarm
-----
The left and middle buttons set the alarm. When it is on, the alarm
time is displayed as a time on a 24 hour clock in the bottom left
corner. It is also indicated by two red triangles, corresponding to the
little (hours) and big (minutes) hand. These hands can be moved around:
the left mouse button moves the minutes hand, the middle button moves
the hourds hand. Watch out for differences of twelve hours (always
check the digital display); these can be corrected by dragging the hours
hand once around the dial.
When the alarm goes off, two things happen: a shell command specified on
the command line with the -a option is executed (in the background), and
the clock's colors change every two seconds, for five minutes. You can
also turn the alarm off by using the menu accessible through the right
mouse button.
There is no default command for the -a option; if it is not specified,
only the changing of the colors happens. If you have an 8 ohm speaker
connected to the audio output of your Personal Iris, a suitable command
would be:
mclock -a '/ufs/guido/bin/sgi/play /ufs/guido/lib/sounds/alarm'
Gong
----
Some people like a clock that makes noises every hour, or even more
often. This is supported by the -g and -G options. With -g you specify
a shell command to be executed to sound the gong; with -G you can
specify the interval between gong calls, in seconds (default is one hour).
The shell command is executed in the background. It is given two
arguments: the hours (on a 24 hour clock!) and the minutes. The
executable Python script /ufs/guido/bin/sgi/chime is a suitable example.
Again, this only works if you have installed a speaker (I bet 8 ohm
speakers are going to be in demand!)
--
Guido van Rossum, Centre for Mathematics and Computer Science (CWI), Amsterdam
guido@cwi.nl or ..!hp4nl!cwi.nl!guido or guido%cwi.nl@uunet.uu.net
"A thing of beauty is a joy till sunrise"
This diff is collapsed.
#! /usr/bin/env python
# Use Gouraud shading to mix colors. Requires Z-buffer.
# It changes the color assignments so fast that you see white.
# Left button pauses, middle rotates the square. ESC to quit.
# Experiment with a larger window (too slow) or smaller window (really white).
from GL import *
from gl import *
import DEVICE
from math import *
#
# tekenvlak : draw a square. with bgnpolygon
#
def tekenvlak (vc) :
bgnpolygon()
#vcarray (vc)
for i in vc :
c3f (i[1])
v3f (i[0])
endpolygon()
#
# tekendoos : draw a box
#
def tekendoos (col) :
v = [(-5.0,0.0,0.0),(0.0,5.0,0.0),(5.0,0.0,0.0),(0.0,-5.0,0.0)]
vc = [(v[0],col[0]),(v[1],col[1]),(v[2],col[2]),(v[3],col[1])]
tekenvlak (vc)
#
# initialize gl
#
def initgl () :
#
# open window
#
foreground ()
keepaspect (1, 1)
prefposition (100, 500, 100, 500)
w = winopen ('PYTHON RGB')
keepaspect (1, 1)
winconstraints()
#
# configure pipeline (2buf, GOURAUD and RGBmode)
#
doublebuffer ()
zbuffer (1)
shademodel (GOURAUD)
RGBmode ()
gconfig ()
#
# set viewing
#
perspective (900, 1, 1.0, 10.0)
polarview (10.0, 0, 0, 0)
#
# ask for the REDRAW and ESCKEY events
#
qdevice(DEVICE.MOUSE2)
qdevice(DEVICE.MOUSE3)
qdevice(DEVICE.REDRAW)
qdevice(DEVICE.ESCKEY)
#
# the color black
#
black = 0
#
# GoForIT : use 2buf to redraw the object 2n times. index i is used as
# the (smoothly changing) rotation angle
#
def GoForIt(i) :
col = [(255.0,0.0,0.0), (0.0,255.0,0.0), (0.0,0.0,255.0)]
twist = 0
freeze = 1
while 1 :
if freeze <> 0 :
col[0],col[1],col[2] = col[1],col[2],col[0]
#
# clear z-buffer and clear background to light-blue
#
zclear()
cpack (black)
clear()
#
tekendoos (col)
#
swapbuffers()
#
if qtest() <> 0 :
dev, val = qread()
if dev == DEVICE.ESCKEY :
break
elif dev == DEVICE.REDRAW :
reshapeviewport ()
elif dev == DEVICE.MOUSE2 and val <> 0 :
twist = twist + 30
perspective (900, 1, 1.0, 10.0)
polarview (10.0, 0, 0, twist)
elif dev == DEVICE.MOUSE3 and val <> 0 :
freeze = 1 - freeze
# the main program
#
def main () :
initgl ()
GoForIt (0)
#
# exec main
#
main ()
#! /usr/bin/env python
# Rotate a 3D surface created using NURBS.
#
# Press left mouse button to toggle surface trimming.
# Press ESC to quit.
#
# See the GL manual for an explanation of NURBS.
from gl import *
from GL import *
from DEVICE import *
TRUE = 1
FALSE = 0
ORDER = 4
idmat = [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
surfknots = [-1, -1, -1, -1, 1, 1, 1, 1]
def make_ctlpoints():
c = []
#
ci = []
ci.append((-2.5, -3.7, 1.0))
ci.append((-1.5, -3.7, 3.0))
ci.append((1.5, -3.7, -2.5))
ci.append((2.5, -3.7, -0.75))
c.append(ci)
#
ci = []
ci.append((-2.5, -2.0, 3.0))
ci.append((-1.5, -2.0, 4.0))
ci.append((1.5, -2.0, -3.0))
ci.append((2.5, -2.0, 0.0))
c.append(ci)
#
ci = []
ci.append((-2.5, 2.0, 1.0))
ci.append((-1.5, 2.0, 0.0))
ci.append((1.5, 2.0, -1.0))
ci.append((2.5, 2.0, 2.0))
c.append(ci)
#
ci = []
ci.append((-2.5, 2.7, 1.25))
ci.append((-1.5, 2.7, 0.1))
ci.append((1.5, 2.7, -0.6))
ci.append((2.5, 2.7, 0.2))
c.append(ci)
#
return c
ctlpoints = make_ctlpoints()
trimknots = [0., 0., 0., 1., 1., 2., 2., 3., 3., 4., 4., 4.]
def make_trimpoints():
c = []
c.append((1.0, 0.0, 1.0))
c.append((1.0, 1.0, 1.0))
c.append((0.0, 2.0, 2.0))
c.append((-1.0, 1.0, 1.0))
c.append((-1.0, 0.0, 1.0))
c.append((-1.0, -1.0, 1.0))
c.append((0.0, -2.0, 2.0))
c.append((1.0, -1.0, 1.0) )
c.append((1.0, 0.0, 1.0))
return c
trimpoints = make_trimpoints()
def main():
init_windows()
setup_queue()
make_lights()
init_view()
#
set_scene()
setnurbsproperty( N_ERRORCHECKING, 1.0 )
setnurbsproperty( N_PIXEL_TOLERANCE, 50.0 )
trim_flag = 0
draw_trim_surface(trim_flag)
#
while 1:
while qtest():
dev, val = qread()
if dev == ESCKEY:
return
elif dev == WINQUIT:
dglclose(-1) # this for DGL only
return
elif dev == REDRAW:
reshapeviewport()
set_scene()
draw_trim_surface(trim_flag)
elif dev == LEFTMOUSE:
if val:
trim_flag = (not trim_flag)
set_scene()
draw_trim_surface(trim_flag)
def init_windows():
foreground()
#prefposition(0, 500, 0, 500)
wid = winopen('nurbs')
wintitle('NURBS Surface')
doublebuffer()
RGBmode()
gconfig()
lsetdepth(0x000, 0x7fffff)
zbuffer( TRUE )
def setup_queue():
qdevice(ESCKEY)
qdevice(REDRAW)
qdevice(RIGHTMOUSE)
qdevice(WINQUIT)
qdevice(LEFTMOUSE) #trimming
def init_view():
mmode(MPROJECTION)
ortho( -4., 4., -4., 4., -4., 4. )
#
mmode(MVIEWING)
loadmatrix(idmat)
#
lmbind(MATERIAL, 1)
def set_scene():
lmbind(MATERIAL, 0)
RGBcolor(150,150,150)
lmbind(MATERIAL, 1)
clear()
zclear()
#
rotate( 100, 'y' )
rotate( 100, 'z' )
def draw_trim_surface(trim_flag):
bgnsurface()
nurbssurface(surfknots, surfknots, ctlpoints, ORDER, ORDER, N_XYZ)
if trim_flag:
bgntrim()
nurbscurve(trimknots, trimpoints, ORDER-1, N_STW)
endtrim()
endsurface()
swapbuffers()
def make_lights():
lmdef(DEFLMODEL,1,[])
lmdef(DEFLIGHT,1,[])
#
# define material #1
#
a = []
a = a + [EMISSION, 0.0, 0.0, 0.0]
a = a + [AMBIENT, 0.1, 0.1, 0.1]
a = a + [DIFFUSE, 0.6, 0.3, 0.3]
a = a + [SPECULAR, 0.0, 0.6, 0.0]
a = a + [SHININESS, 2.0]
a = a + [LMNULL]
lmdef(DEFMATERIAL, 1, a)
#
# turn on lighting
#
lmbind(LIGHT0, 1)
lmbind(LMODEL, 1)
main()
#! /usr/bin/env python
# zrgb (Requires Z buffer.)
#
# This program demostrates zbuffering 3 intersecting RGB polygons while
# in doublebuffer mode where, movement of the mouse with the LEFTMOUSE
# button depressed will, rotate the 3 polygons. This is done by compound
# rotations allowing continuous screen-oriented rotations.
#
# Press the "Esc" key to exit.
from gl import *
from GL import *
from DEVICE import *
idmat=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]
def main() :
#
# old and new mouse position
#
#
mode = 0
omx = 0
mx = 0
omy = 0
my = 0
#
objmat=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]
#
initialize ()
#
draw_scene (objmat)
#
while (1) :
#
dev, val = qread()
#
if dev == ESCKEY :
if val :
break
# exit when key is going up, not down
# this avoids the scenario where a window
# underneath this program's window
# would otherwise "eat up" the up-
# event of the Esc key being released
return
#
elif dev == REDRAW :
reshapeviewport()
draw_scene(objmat)
#
elif dev == LEFTMOUSE:
omx = mx
omy = my
if val :
mode = 1
else :
mode = 0
elif dev == MOUSEX :
omx = mx
mx = val
#print omx, mx
objmat = update_scene(objmat,mx,my,omx,omy,mode)
#
elif dev == MOUSEY :
omy = my
my = val
#print omy, my
objmat = update_scene(objmat,mx,my,omx,omy,mode)
#
def initialize () :
#
foreground ()
keepaspect(5, 4)
w = winopen('Zbuffered RGB')
#
doublebuffer()
RGBmode()
gconfig()
zbuffer(1)
lsetdepth(0x0, 0x7FFFFF)
#
qdevice(ESCKEY)
qdevice(LEFTMOUSE)
qdevice(MOUSEX)
qdevice(MOUSEY)
def update_scene (mat, mx, my, omx, omy, mode) :
#
if mode == 1 :
mat = orient(mat, mx, my, omx, omy)
draw_scene(mat)
return mat
def orient (mat, mx, my, omx, omy) :
#
#
pushmatrix()
loadmatrix(idmat)
#
if mx - omx : rot (float (mx - omx), 'y')
if omy - my : rot (float (omy - my), 'x')
#
multmatrix(mat)
mat = getmatrix()
#
popmatrix()
#
return mat
def draw_scene (mat) :
RGBcolor(40, 100, 200)
clear()
zclear()
#
perspective(400, 1.25, 30.0, 60.0)
translate(0.0, 0.0, -40.0)
multmatrix(mat)
#
# skews original view to show all polygons
#
rotate(-580, 'y')
draw_polys()
#
swapbuffers()
polygon1 = [(-10.0,-10.0,0.0),(10.0,-10.0,0.0),(-10.0,10.0,0.0)]
polygon2 = [(0.0,-10.0,-10.0),(0.0,-10.0,10.0),(0.0,5.0,-10.0)]
polygon3 = [(-10.0,6.0,4.0),(-10.0,3.0,4.0),(4.0,-9.0,-10.0),(4.0,-6.0,-10.0)]
def draw_polys():
bgnpolygon()
cpack(0x0)
v3f(polygon1[0])
cpack(0x007F7F7F)
v3f(polygon1[1])
cpack(0x00FFFFFF)
v3f(polygon1[2])
endpolygon()
#
bgnpolygon()
cpack(0x0000FFFF)
v3f(polygon2[0])
cpack(0x007FFF00)
v3f(polygon2[1])
cpack(0x00FF0000)
v3f(polygon2[2])
endpolygon()
#
bgnpolygon()
cpack(0x0000FFFF)
v3f(polygon3[0])
cpack(0x00FF00FF)
v3f(polygon3[1])
cpack(0x00FF0000)
v3f(polygon3[2])
cpack(0x00FF00FF)
v3f(polygon3[3])
endpolygon()
main ()
# Live video input from display class.
import gl
import GL
# The live video input class.
# Only instantiate this if have_video is true!
class DisplayVideoIn:
# Initialize an instance. Arguments:
# vw, vh: size of the video window data to be captured.
# position defaults to 0, 0 but can be set later
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
# Change the size of the video being displayed.
def resizevideo(self, vw, vh):
self.width = vw
self.height = vh
self.x1 = self.x0 + self.width - 1
self.y1 = self.y0 + self.height - 1
def positionvideo(self, x, y):
self.x0 = x
self.y0 = y
self.x1 = self.x0 + self.width - 1
self.y1 = self.y0 + self.height - 1
# Remove an instance.
# This turns off continuous capture.
def close(self):
gl.winclose(self.wid)
# Get the length in bytes of a video line
def linewidth(self):
return self.width*4
# Get the next video packet.
# This returns (lpos, data) where:
# - lpos is the line position
# - data is a piece of data
# The dimensions of data are:
# - pixel depth = 1 byte
# - scan line width = self.width (the vw argument to __init__())
# - number of scan lines = self.lpp (PKTMAX / vw)
def getnextpacket(self):
if not self.data or self.dataoffset >= len(self.data):
self.old_data = self.data
self.data = gl.readdisplay(self.x0, self.y0, \
self.x1, self.y1, self.hints)
self.dataoffset = 0
self.lpos = 0
data = self.data[self.dataoffset:self.dataoffset+self.pktsize]
while self.old_data and \
self.dataoffset+self.pktsize < len(self.data):
odata = self.old_data[self.dataoffset: \
self.dataoffset+self.pktsize]
if odata <> data:
break
print 'skip', self.lpos
self.lpos = self.lpos + self.lpp
self.dataoffset = self.dataoffset + self.pktsize
data = self.data[self.dataoffset:\
self.dataoffset+self.pktsize]
lpos = self.lpos
self.dataoffset = self.dataoffset + self.pktsize
self.lpos = self.lpos + self.lpp
return lpos, data
#! /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` + ')'
print '-v : print packet rate'
print '-x xpos : set x position'
print '-y ypos : set y position'
print '[host] ...: host(s) to send to (default multicast to ' + \
DEFMCAST + ')'
sys.exit(2)
def main():
sys.stdout = sys.stderr
hosts = []
port = DEFPORT
ttl = -1
pktmax = DEFPKTMAX
width = DEFWIDTH
height = DEFHEIGHT
vtype = 'rgb'
verbose = 0
xpos = ypos = 0
try:
opts, args = getopt.getopt(sys.argv[1:], 'bh:p:s:S:t:w:vx:y:')
except getopt.error, msg:
usage(msg)
try:
for opt, optarg in opts:
if opt == '-p':
port = string.atoi(optarg)
if opt == '-b':
host = '<broadcast>'
if opt == '-t':
ttl = string.atoi(optarg)
if opt == '-S':
pktmax = string.atoi(optarg)
vidmax = SV.PAL_XMAX*SV.PAL_YMAX
if vidmax <= pktmax:
width = SV.PAL_XMAX
height = SV.PAL_YMAX
pktmax = vidmax
else:
factor = float(vidmax)/float(pktmax)
factor = math.sqrt(factor)
width = int(SV.PAL_XMAX/factor)-7
height = int(SV.PAL_YMAX/factor)-5
print 'video:',width,'x',height,
print 'pktsize',width*height,'..',
print pktmax
if opt == '-s':
pktmax = string.atoi(optarg)
if opt == '-w':
width = string.atoi(optarg)
if opt == '-h':
height = string.atoi(optarg)
if opt == '-c':
vtype = optarg
if opt == '-v':
verbose = 1
if opt == '-x':
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)
if xpos or ypos:
lvi.positionvideo(xpos, ypos)
s = socket(AF_INET, SOCK_DGRAM)
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
if ttl >= 0:
s.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, chr(ttl))
frozen = 0
lasttime = int(time.time())
nframe = 0
while 1:
if gl.qtest():
dev, val = gl.qread()
if dev in (DEVICE.ESCKEY, \
DEVICE.WINSHUT, DEVICE.WINQUIT):
break
if dev == DEVICE.WINFREEZE:
frozen = 1
if dev == DEVICE.WINTHAW:
frozen = 0
if dev == DEVICE.REDRAW:
w, h = gl.getsize()
x, y = gl.getorigin()
if (w, h) <> (width, height):
width, height = w, h
lvi.resizevideo(width, height)
lvo.resizevideo(width, height)
rv = lvi.getnextpacket()
if not rv:
time.sleep(0.010)
continue
pos, data = rv
print pos, len(data) # DBG
if not frozen:
lvo.putnextpacket(pos, data)
hdr = struct.pack('hhh', pos, width, height)
for host in hosts:
try:
# print len(hdr+data) # DBG
s.sendto(hdr + data, (host, port))
except error, msg: # really socket.error
if msg[0] <> 121: # no buffer space available
raise error, msg # re-raise it
print 'Warning:', msg[1]
if pos == 0 and verbose:
nframe = nframe+1
if int(time.time()) <> lasttime:
print nframe / (time.time()-lasttime), 'fps'
nframe = 0
lasttime = int(time.time())
lvi.close()
lvo.close()
main()
# Live video input class.
# Note that importing this module attempts to initialize video.
# Check if video is available.
# There are three reasons for failure here:
# (1) this version of Python may not have the sv or imageop modules;
# (2) this machine may not have a video board;
# (3) initializing the video board may fail for another reason.
# The global variable have_video is set to true iff we reall do have video.
try:
import sv
import SV
import imageop
try:
v = sv.OpenVideo()
have_video = 1
except sv.error:
have_video = 0
except ImportError:
have_video = 0
# The live video input class.
# Only instantiate this if have_video is true!
class LiveVideoIn:
# Initialize an instance. Arguments:
# vw, vh: size of the video window data to be captured.
# For some reason, vw MUST be a multiple of 4.
# Note that the data has to be cropped unless vw and vh are
# just right for the video board (vw:vh == 4:3 and vh even).
def __init__(self, pktmax, vw, vh, type):
if not have_video:
raise RuntimeError, 'no video available'
if vw % 4 != 0:
raise ValueError, 'vw must be a multiple of 4'
self.pktmax = pktmax
realvw = vh*SV.PAL_XMAX/SV.PAL_YMAX
if realvw < vw:
realvw = vw
self.realwidth, self.realheight = v.QuerySize(realvw, vh)
if not type in ('rgb8', 'grey', 'mono', 'grey2', 'grey4'):
raise 'Incorrent video data type', type
self.type = type
if type in ('grey', 'grey4', 'grey2', 'mono'):
v.SetParam([SV.COLOR, SV.MONO, SV.INPUT_BYPASS, 1])
else:
v.SetParam([SV.COLOR, SV.DEFAULT_COLOR, \
SV.INPUT_BYPASS, 0])
# Initialize capture
(mode, self.realwidth, self.realheight, qsize, rate) = \
v.InitContinuousCapture(SV.RGB8_FRAMES, \
self.realwidth, self.realheight, 1, 2)
self.width = vw
self.height = vh
self.x0 = (self.realwidth-self.width)/2
self.x1 = self.x0 + self.width - 1
self.y0 = (self.realheight-self.height)/2
self.y1 = self.y0 + self.height - 1
# Compute # full lines per packet
self.lpp = pktmax / self.linewidth()
self.pktsize = self.lpp*self.linewidth()
self.data = None
self.dataoffset = 0
self.lpos = 0
self.justright = (self.realwidth == self.width and \
self.realheight == self.height)
## if not self.justright:
## print 'Want:', self.width, 'x', self.height,
## print '; grab:', self.realwidth, 'x', self.realheight
# Change the size of the video being displayed.
def resizevideo(self, vw, vh):
self.close()
self.__init__(self.pktmax, vw, vh, self.type)
# Remove an instance.
# This turns off continuous capture.
def close(self):
v.EndContinuousCapture()
# Get the length in bytes of a video line
def linewidth(self):
if self.type == 'mono':
return (self.width+7)/8
elif self.type == 'grey2':
return (self.width+3)/4
elif self.type == 'grey4':
return (self.width+1)/2
else:
return self.width
# Get the next video packet.
# This returns (lpos, data) where:
# - lpos is the line position
# - data is a piece of data
# The dimensions of data are:
# - pixel depth = 1 byte
# - scan line width = self.width (the vw argument to __init__())
# - number of scan lines = self.lpp (PKTMAX / vw)
def getnextpacket(self):
if not self.data or self.dataoffset >= len(self.data):
try:
cd, id = v.GetCaptureData()
except sv.error:
return None
data = cd.InterleaveFields(1)
cd.UnlockCaptureData()
if self.justright:
self.data = data
else:
self.data = imageop.crop(data, 1, \
self.realwidth, \
self.realheight, \
self.x0, self.y0, \
self.x1, self.y1)
self.lpos = 0
self.dataoffset = 0
if self.type == 'mono':
self.data = imageop.dither2mono(self.data, \
self.width, self.height)
elif self.type == 'grey2':
self.data = imageop.dither2grey2(self.data, \
self.width, self.height)
elif self.type == 'grey4':
self.data = imageop.grey2grey4(self.data, \
self.width, self.height)
data = self.data[self.dataoffset:self.dataoffset+self.pktsize]
lpos = self.lpos
self.dataoffset = self.dataoffset + self.pktsize
self.lpos = self.lpos + self.lpp
return lpos, data
# Live video output (display video on the screen, presumably from the net)
import gl
from VFile import Displayer
# Video output (displayer) class.
class LiveVideoOut:
# Call this to initialize things. Arguments:
# wid: the window id where the video is to be displayed (centered)
# vw, vh: size of the video image to be displayed
def __init__(self, wid, vw, vh, type):
##print 'Init', wid, xywh
##print 'video', vw, vw
self.vw = vw
self.vh = vh
self.disp = Displayer()
if not type in ('rgb', 'rgb8', 'grey', 'mono', 'grey2', \
'grey4'):
raise 'Incorrent live video output type', type
if type == 'rgb':
info = (type, vw, vh, 0, 32, 0, 0, 0, 0)
else:
info = (type, vw, vh, 1, 8, 0, 0, 0, 0)
self.disp.setinfo(info)
self.wid = wid
oldwid = gl.winget()
gl.winset(wid)
self.disp.initcolormap()
self.reshapewindow()
gl.winset(oldwid)
# Call this in response to every REDRAW event for the window
# or if the window size has changed for other reasons.
def reshapewindow(self):
oldwid = gl.winget()
gl.winset(self.wid)
gl.reshapeviewport()
w, h = gl.getsize()
self.disp.xorigin = (w-self.vw)/2
self.disp.yorigin = (h-self.vh)/2
self.disp.clear()
gl.winset(oldwid)
# Call this to change the size of the video images being displayed.
# Implies reshapewindow().
def resizevideo(self, vw, vh):
self.vw, self.vh = vw, vh
self.disp.setsize(vw, vh)
self.reshapewindow()
# Return the number of bytes in one video line
def linewidth(self):
if self.disp.format == 'rgb':
return self.vw*4
if self.disp.format == 'mono':
return (self.vw+7)/8
elif self.disp.format == 'grey2':
return (self.vw+3)/4
elif self.disp.format == 'grey4':
return (self.vw+1)/2
else:
return self.vw
# Call this to display the next video packet. Arguments:
# pos: line number where the packet begins
# data: image data of the packet
# (these correspond directly to the return values from
# LiveVideoIn.getnextpacket()).
def putnextpacket(self, pos, data):
nline = len(data)/self.linewidth()
if nline*self.linewidth() <> len(data):
print 'Incorrect-sized video fragment ignored'
return
oldwid = gl.winget()
gl.winset(self.wid)
self.disp.showpartframe(data, None, (0, pos, self.vw, nline))
gl.winset(oldwid)
# Call this to close the window.
def close(self):
pass
# Call this to set optional mirroring of video
def setmirror(self, mirrored):
f, w, h, pf, c0, c1, c2, o, cp = self.disp.getinfo()
if type(pf) == type(()):
xpf, ypf = pf
else:
xpf = ypf = pf
xpf = abs(xpf)
if mirrored:
xpf = -xpf
info = (f, w, h, (xpf, ypf), c0, c1, c2, o, cp)
self.disp.setinfo(info)
self.disp.initcolormap()
self.disp.clear()
#
# This derived class has one difference with the base class: the video is
# not displayed until an entire image has been gotten
#
class LiveVideoOutSlow(LiveVideoOut):
# Reshapewindow - Realloc buffer.
# (is also called by __init__() indirectly)
def reshapewindow(self):
LiveVideoOut.reshapewindow(self)
self.buffer = '\0'*self.linewidth()*self.vh
self.isbuffered = []
# putnextpacket - buffer incoming data until a complete
# image has been received
def putnextpacket(self, pos, data):
if pos in self.isbuffered or pos == 0:
LiveVideoOut.putnextpacket(self, 0, self.buffer)
self.isbuffered = []
self.isbuffered.append(pos)
bpos = pos * self.linewidth()
epos = bpos + len(data)
self.buffer = self.buffer[:bpos] + data + self.buffer[epos:]
#! /usr/bin/env python
# Copy a video file, interactively, frame-by-frame.
import sys
import getopt
from gl import *
from DEVICE import *
import VFile
import VGrabber
import string
import imageop
def report(time, iframe):
print 'Frame', iframe, ': t =', time
def usage():
sys.stderr.write('usage: Vcopy [-t type] [-m threshold] [-a] infile outfile\n')
sys.stderr.write('-t Convert to other type\n')
sys.stderr.write('-a Automatic\n')
sys.stderr.write('-m Convert grey to mono with threshold\n')
sys.stderr.write('-d Convert grey to mono with dithering\n')
sys.exit(2)
def help():
print 'Command summary:'
print 'n get next image from input'
print 'w write current image to output'
class GrabbingVoutFile(VFile.VoutFile, VGrabber.VGrabber):
pass
def main():
foreground()
try:
opts, args = getopt.getopt(sys.argv[1:], 't:am:d')
except getopt.error, msg:
print msg
usage()
if len(args) <> 2:
usage()
[ifile, ofile] = args
print 'open film ', ifile
ifilm = VFile.VinFile(ifile)
print 'open output ', ofile
ofilm = GrabbingVoutFile(ofile)
ofilm.setinfo(ifilm.getinfo())
use_grabber = 0
continuous = 0
tomono = 0
tomonodither = 0
for o, a in opts:
if o == '-t':
ofilm.format = a
use_grabber = 1
if o == '-a':
continuous = 1
if o == '-m':
if ifilm.format <> 'grey':
print '-m only supported for greyscale'
sys.exit(1)
tomono = 1
treshold = string.atoi(a)
ofilm.format = 'mono'
if o == '-d':
if ifilm.format <> 'grey':
print '-m only supported for greyscale'
sys.exit(1)
tomonodither = 1
ofilm.format = 'mono'
ofilm.writeheader()
#
prefsize(ifilm.width, ifilm.height)
w = winopen(ifile)
qdevice(KEYBD)
qdevice(ESCKEY)
qdevice(WINQUIT)
qdevice(WINSHUT)
print 'qdevice calls done'
#
help()
#
time, data, cdata = ifilm.getnextframe()
ifilm.showframe(data, cdata)
iframe = 1
report(time, iframe)
#
while 1:
if continuous:
dev = KEYBD
else:
dev, val = qread()
if dev in (ESCKEY, WINQUIT, WINSHUT):
break
if dev == REDRAW:
reshapeviewport()
elif dev == KEYBD:
if continuous:
c = '0'
else:
c = chr(val)
#XXX Debug
if c == 'R':
c3i(255,0,0)
clear()
if c == 'G':
c3i(0,255,0)
clear()
if c == 'B':
c3i(0,0,255)
clear()
if c == 'w' or continuous:
if use_grabber:
try:
data, cdata = ofilm.grabframe()
except VFile.Error, msg:
print msg
break
if tomono:
data = imageop.grey2mono(data, \
ifilm.width, ifilm.height, \
treshold)
if tomonodither:
data = imageop.dither2mono(data, \
ifilm.width, ifilm.height)
ofilm.writeframe(time, data, cdata)
print 'Frame', iframe, 'written.'
if c == 'n' or continuous:
try:
time,data,cdata = ifilm.getnextframe()
ifilm.showframe(data, cdata)
iframe = iframe+1
report(time, iframe)
except EOFError:
print 'EOF'
if continuous:
break
ringbell()
elif dev == INPUTCHANGE:
pass
else:
print '(dev, val) =', (dev, val)
ofilm.close()
main()
CMIF video tools
================
This directory contains Python and C programs to manipulate files
containing digitized video in the "CMIF video format".
An introduction to using the basic tools is in the file "video.doc".
A description of the video file format is in the file "cmif-film.ms"
(troff/nroff -ms input).
History
-------
We started this in October 1991, when we had a large framegrabber
board on loan from SGI for a few weeks: we developed a movie recording
program and added numerous features, including still frame capture and
synchronous sound recording using a second machine (the machine
holding the framegrabber board didn't have audio).
During the following months, when we started using and processing the
recorded film fragments, the "CMIF video format" was revised several
times, and we eventually created an object-oriented interface for
reading and writing various incarnations of these files, called VFile.
(This module is also used by our flagship application, the CMIF
editor, not in this directory but in /ufs/guido/mm/.)
When we got our own Indigo entry-level video board (in June 1992) and
a version of the Irix video library that supported capturing PAL
format (in August 1992), Sjoerd added an interface to the video
library to Python (sv) and Guido wrote Vrec.py (based upon a still
frame grabber by Sjoerd, in turn based upon SGI demo code in C) to
record a movie using it. Vrec was soon followed by modernized
versions of the other programs (Vinfo, Vplay, Vtime) and an
interactive editor (Vedit). Finally, VFile was rewritten for more
modularity, functionality and robustness, and various other tools were
added as needed. Also, new options were added to existing tools, and
several new video file formats were added.
Guido van Rossum
Jack Jansen
Sjoerd Mullender
Overview of files
-----------------
cmif-film.ms description of the CMIF video file format (more than a
little out of date -- read the source for VFile for
more info about new file formats)
These are programs with a command line interface:
Vrec.py record video movies using the Indigo video library and
board
Vplay.py play video movies
Vinfo.py show statistics on movies
Vtime.py Copy a video file, manipulating the time codes (e.g.
faster/slower, or regenerate time codes, or drop
frames too close apart)
Vcopy.py Universal video file copying tool. Can manipulate the
time codes, change the type, size, and packfactor.
Subsumes Vtime.py.
Vmkjpeg.py compress an rgb or grey video file to jpeg[grey] format
Vunjpeg.py expand a jpeg[grey] video file to rgb or grey format
Vfix.py truncate the scan line width of a video file to
a multiple of 4 ('grey' images only)
Vedit.py interactive video editing program (uses the FORMS library)
Vsend.py unicast or multicast live video as UDP packets
Vreceive.py receive transmissions from Vsend
Vaddcache.py add a "cached index" to a video file, for faster playing
Vrecb.py like Vrec.py but uses "burst capture" -- somewhat specialized
Dsend.py like Vsend.py but sends screen snapshots (to Vreceive.py)
DisplayVideoIn.py Like LiveVideoIn.py but reads screen snapshots
rgb2video.py combine a sequence of rgb image files into a CMIF video file
video2rgb.py split a CMIF video file into a sequence of rgb image files
These modules and files are used by the above programs:
VFile.py classes that read and write CMIF video files
Viewer.py two viewer classes used by Vedit
LiveVideoIn.py live video input class, used by Vsend
LiveVideoOut.py live video output class, used by Vsend and Vreceive
imgconv.py Image conversion subroutines for rgb2video.py
senddefs.py Defaults shared by Vsend and Vreceice
watchcursor.py Generally useful module to define a watch cursor in GL
VeditForm.fd FORMS' fdesign definition for Vedit's form
This diff is collapsed.
This diff is collapsed.
# Class to grab frames from a window.
# (This has fewer user-settable parameters than Displayer.)
# It is the caller's responsibility to initialize the window and to
# ensure that it is current when using grabframe()
import gl, GL
import VFile
import GET
from VFile import Error
class VGrabber(VFile.VideoParams):
# XXX The constructor of VideoParams is just fine, for now
# Grab a frame.
# Return (data, chromdata) just like getnextframe().
def grabframe(self):
grabber = choose_grabber(self.format)
return grabber(self.width, self.height, self.packfactor)
# Choose one of the grabber functions below based upon a color system name
def choose_grabber(format):
try:
return eval('grab_' + format)
except:
raise Error, 'Unknown color system: ' + `format`
# Routines to grab data, per color system (only a few really supported).
# (These functions are used via eval with a constructed argument!)
def grab_rgb(w, h, pf):
if gl.getdisplaymode() <> GET.DMRGB:
raise Error, 'Sorry, can only grab rgb in single-buf rgbmode'
if pf <> (1, 1):
raise Error, 'Sorry, only grab rgb with packfactor (1,1)'
return gl.lrectread(0, 0, w-1, h-1), None
def grab_rgb8(w, h, pf):
if gl.getdisplaymode() <> GET.DMRGB:
raise Error, 'Sorry, can only grab rgb8 in single-buf rgbmode'
if pf <> (1, 1):
raise Error, 'Sorry, can only grab rgb8 with packfactor (1,1)'
if not VFile.is_entry_indigo():
raise Error, 'Sorry, can only grab rgb8 on entry level Indigo'
# XXX Dirty Dirty here.
# XXX Set buffer to cmap mode, grab image and set it back.
gl.cmode()
gl.gconfig()
gl.pixmode(GL.PM_SIZE, 8)
data = gl.lrectread(0, 0, w-1, h-1)
data = data[:w*h] # BUG FIX for python lrectread
gl.RGBmode()
gl.gconfig()
gl.pixmode(GL.PM_SIZE, 32)
return data, None
def grab_grey(w, h, pf):
raise Error, 'Sorry, grabbing grey not implemented'
def grab_yiq(w, h, pf):
raise Error, 'Sorry, grabbing yiq not implemented'
def grab_hls(w, h, pf):
raise Error, 'Sorry, grabbing hls not implemented'
def grab_hsv(w, h, pf):
raise Error, 'Sorry, grabbing hsv not implemented'
def grab_jpeg(w, h, pf):
data, dummy = grab_rgb(w, h, pf)
import jpeg
data = jpeg.compress(data, w, h, 4)
return data, None
def grab_jpeggrey(w, h, pf):
raise Error, 'sorry, grabbing jpeggrey not implemented'
#! /usr/bin/env python
# Add a cache to each of the files given as command line arguments
# Usage:
#
# Vaddcache [file] ...
# Options:
#
# file ... : file(s) to modify; default film.video
import sys
sys.path.append('/ufs/guido/src/video')
import VFile
import getopt
# Global options
# None
# Main program -- mostly command line parsing
def main():
opts, args = getopt.getopt(sys.argv[1:], '')
if not args:
args = ['film.video']
sts = 0
for filename in args:
if process(filename):
sts = 1
sys.exit(sts)
# Process one file
def process(filename):
try:
fp = open(filename, 'r+')
vin = VFile.RandomVinFile(fp)
vin.filename = filename
except IOError, msg:
sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n')
return 1
except VFile.Error, msg:
sys.stderr.write(msg + '\n')
return 1
except EOFError:
sys.stderr.write(filename + ': EOF in video file\n')
return 1
try:
vin.readcache()
hascache = 1
except VFile.Error:
hascache = 0
if hascache:
sys.stderr.write(filename + ': already has a cache\n')
vin.close()
return 1
vin.printinfo()
vin.warmcache()
vin.writecache()
vin.close()
return 0
# Don't forget to call the main program
try:
main()
except KeyboardInterrupt:
print '[Interrupt]'
This diff is collapsed.
Magic: 12321
Internal Form Definition File
(do not change)
Number of forms: 1
=============== FORM ===============
Name: form
Width: 450.000000
Height: 260.000000
Number of Objects: 40
--------------------
class: 1
type: 1
box: 0.000000 0.000000 450.000000 260.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name:
callback:
argument:
--------------------
class: 11
type: 5
box: 330.000000 150.000000 110.000015 60.000004
boxtype: 1
colors: 47 47
alignment: 4
style: 1
size: 11.000000
lcol: 0
label: Capture
name: b_capture
callback: cb_capture
argument: 0
--------------------
class: 11
type: 0
box: 330.000000 10.000000 110.000008 30.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: Quit
name: b_quit
callback: cb_quit
argument: 0
--------------------
class: 11
type: 0
box: 330.000000 50.000000 110.000000 30.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: Playback
name: b_play
callback: cb_play
argument: 0
--------------------
class: 42
type: 0
box: 80.000000 220.000000 120.000000 30.000000
boxtype: 5
colors: 7 0
alignment: 2
style: 0
size: 11.000000
lcol: 0
label: Format:
name: c_vformat
callback: cb_vformat
argument: 0
--------------------
class: 11
type: 0
box: 330.000000 220.000000 110.000000 30.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: Reset
name: b_reset
callback: cb_reset
argument: 0
--------------------
class: 42
type: 0
box: 80.000000 50.000000 120.000000 30.000000
boxtype: 5
colors: 7 0
alignment: 2
style: 0
size: 11.000000
lcol: 0
label: Format:
name: c_aformat
callback: cb_aformat
argument: 0
--------------------
class: 10000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 1668246586 540019308
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name: g_audio
callback:
argument:
--------------------
class: 11
type: 0
box: 10.000000 10.000000 190.000000 30.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: Set audio file...
name: b_afile
callback: cb_afile
argument: 0
--------------------
class: 20000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 876099360 892416522
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name:
callback:
argument:
--------------------
class: 10000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 1147496041 1852404841
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name: g_video
callback:
argument:
--------------------
class: 42
type: 0
box: 80.000000 180.000000 120.000000 30.000000
boxtype: 5
colors: 7 0
alignment: 2
style: 0
size: 11.000000
lcol: 0
label: Mode:
name: c_vmode
callback: cb_vmode
argument: 0
--------------------
class: 11
type: 0
box: 10.000000 90.000000 190.000000 30.000000
boxtype: 1
colors: 47 47
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: Set video file...
name: b_vfile
callback: cb_vfile
argument: 0
--------------------
class: 20000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 544171552 1331849829
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name:
callback:
argument:
--------------------
class: 10000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 0 0
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name: g_single
callback:
argument:
--------------------
class: 31
type: 2
box: 220.000000 150.000000 100.000000 30.000000
boxtype: 2
colors: 13 5
alignment: 0
style: 0
size: 11.000000
lcol: 0
label: Frames/sec
name: in_fps
callback: cb_fps
argument: 0
--------------------
class: 20000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 0 0
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name:
callback:
argument:
--------------------
class: 10000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 0 0
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name: g_burst
callback:
argument:
--------------------
class: 31
type: 1
box: 220.000000 150.000000 100.000000 30.000000
boxtype: 2
colors: 13 5
alignment: 0
style: 0
size: 11.000000
lcol: 0
label: Max Mbytes:
name: in_maxmem
callback: cb_maxmem
argument: 0
--------------------
class: 31
type: 2
box: 220.000000 90.000000 100.000000 30.000000
boxtype: 2
colors: 13 5
alignment: 0
style: 0
size: 11.000000
lcol: 0
label: Nr. of frames:
name: in_nframes
callback: cb_nframes
argument: 0
--------------------
class: 20000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 0 0
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name:
callback:
argument:
--------------------
class: 10000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 0 0
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name: g_cont
callback:
argument:
--------------------
class: 31
type: 2
box: 250.000000 150.000000 40.000000 30.000000
boxtype: 2
colors: 13 5
alignment: 0
style: 0
size: 11.000000
lcol: 0
label: Capture rate:
name: in_rate
callback: cb_rate
argument: 0
--------------------
class: 2
type: 0
box: 220.000000 150.000000 30.000000 30.000000
boxtype: 0
colors: 47 47
alignment: 2
style: 0
size: 11.000000
lcol: 0
label: 1/
name:
callback:
argument:
--------------------
class: 2
type: 0
box: 290.000000 150.000000 30.000000 30.000000
boxtype: 0
colors: 47 47
alignment: 2
style: 0
size: 11.000000
lcol: 0
label: fr
name:
callback:
argument:
--------------------
class: 13
type: 0
box: 220.000000 90.000000 100.000000 30.000000
boxtype: 0
colors: 7 3
alignment: 4
style: 0
size: 11.000000
lcol: 0
label: Fielddrop
name: b_drop
callback: cb_drop
argument: 0
--------------------
class: 20000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 0 0
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name:
callback:
argument:
--------------------
class: 2
type: 0
box: 330.000000 90.000000 110.000000 30.000002
boxtype: 2
colors: 47 47
alignment: 2
style: 0
size: 11.000000
lcol: 0
label:
name: t_nframes
callback:
argument:
--------------------
class: 2
type: 0
box: 330.000000 120.000000 110.000000 30.000000
boxtype: 0
colors: 47 47
alignment: 2
style: 0
size: 11.000000
lcol: 0
label: Frames done:
name:
callback:
argument:
--------------------
class: 10000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 640 235
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name: g_vcr
callback:
argument:
--------------------
class: 31
type: 2
box: 220.000000 90.000000 100.000000 30.000000
boxtype: 2
colors: 13 5
alignment: 0
style: 0
size: 11.000000
lcol: 0
label: # frames wtd:
name: in_nframes_vcr
callback: cb_nframes_vcr
argument: 0
--------------------
class: 31
type: 2
box: 220.000000 150.000000 100.000000 30.000000
boxtype: 2
colors: 13 5
alignment: 0
style: 0
size: 11.000000
lcol: 0
label: Sample rate:
name: in_rate_vcr
callback: cb_rate_vcr
argument: 0
--------------------
class: 42
type: 0
box: 220.000000 10.000000 100.000000 30.000000
boxtype: 5
colors: 7 0
alignment: 0
style: 0
size: 11.000000
lcol: 0
label: VCR speed:
name: c_vcrspeed
callback: cb_vcrspeed
argument: 0
--------------------
class: 20000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 640 235
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name:
callback:
argument:
--------------------
class: 10000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 58720287 33751040
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name: g_rgb24
callback:
argument:
--------------------
class: 42
type: 0
box: 260.000000 220.000000 60.000000 30.000000
boxtype: 5
colors: 7 0
alignment: 2
style: 0
size: 11.000000
lcol: 0
label: Size:
name: c_rgb24_size
callback: cb_rgb24_size
argument: 0
--------------------
class: 20000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 0 0
alignment: 4
style: 0
size: 11.000000
lcol: 0
label:
name:
callback:
argument:
--------------------
class: 10000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 0 0
alignment: 4
style: 0
size: 10.000000
lcol: 0
label:
name: g_compress
callback:
argument:
--------------------
class: 42
type: 0
box: 80.000000 140.000000 120.000000 30.000000
boxtype: 5
colors: 7 0
alignment: 2
style: 0
size: 11.000000
lcol: 0
label: Scheme:
name: c_cformat
callback: cb_cformat
argument: 0
--------------------
class: 20000
type: 0
box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0
colors: 0 0
alignment: 4
style: 0
size: 10.000000
lcol: 0
label:
name:
callback:
argument:
==============================
create_the_forms
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import sys, posixpath
exec('import ' + posixpath.basename(sys.argv[0]) + '\n')
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#! /usr/bin/env python
# Print the value of all video parameters
import sys
import sv, SV
def main():
v = sv.OpenVideo()
for name in dir(SV):
const = getattr(SV, name)
if type(const) is type(0):
sys.stdout.flush()
params = [const, 0]
try:
v.GetParam(params)
except sv.error, msg:
## print name, msg
continue
print name, params
main()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment