Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db96c5a

Browse files
committed
Initial revision
1 parent 62f6bc8 commit db96c5a

5 files changed

Lines changed: 262 additions & 0 deletions

File tree

Demo/sgi/sv/README

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Demo programs for the SGI Video library for the Indigo (IRIX 4.0.5).
2+
These are more-or-less literal translations of the C programs from the
3+
Indigo Video Programming Guide, by Sjoerd Mullender, with minor
4+
changes by Guido.
5+
6+
simpleinput.py Live video in a resizable window
7+
rgbgrab.py Grab still frames
8+
contcapt.py Continuous capturing (to a window)
9+
burstcapt.py Burst capturing

Demo/sgi/sv/burstcapt.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import sv, SV
2+
import gl, GL, DEVICE
3+
4+
def main():
5+
format = SV.RGB8_FRAMES
6+
requestedwidth = SV.PAL_XMAX
7+
queuesize = 2
8+
9+
v = sv.OpenVideo()
10+
svci = (format, requestedwidth, 0, queuesize, 0)
11+
12+
svci, buffer, bitvec = v.CaptureBurst(svci)
13+
[bitvec]
14+
15+
w, h = svci[1:3]
16+
framesize = w * h
17+
18+
gl.prefposition(300, 300+w-1, 100, 100+h-1)
19+
gl.foreground()
20+
win = gl.winopen('Burst Capture')
21+
gl.RGBmode()
22+
gl.gconfig()
23+
gl.qdevice(DEVICE.LEFTMOUSE)
24+
gl.qdevice(DEVICE.ESCKEY)
25+
26+
for i in range(svci[3]):
27+
inverted_frame = sv.RGB8toRGB32(1, \
28+
buffer[i*framesize:(i+1)*framesize], w, h)
29+
gl.lrectwrite(0, 0, w-1, h-1, inverted_frame)
30+
while 1:
31+
dev, val = gl.qread()
32+
if dev == DEVICE.LEFTMOUSE and val == 1:
33+
break
34+
if dev == DEVICE.REDRAW:
35+
gl.lrectwrite(0, 0, w-1, h-1, inverted_frame)
36+
if dev == DEVICE.ESCKEY:
37+
v.CloseVideo()
38+
gl.winclose(win)
39+
return
40+
v.CloseVideo()
41+
gl.winclose(win)
42+
43+
main()

Demo/sgi/sv/contcapt.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import sys
2+
import sv, SV
3+
import gl, GL, DEVICE
4+
5+
def main():
6+
format = SV.RGB8_FRAMES
7+
framerate = 25
8+
queuesize = 16
9+
samplingrate = 2
10+
11+
v = sv.OpenVideo()
12+
# Determine maximum window size based on signal standard
13+
param = [SV.BROADCAST, 0]
14+
v.GetParam(param)
15+
if param[1] == SV.PAL:
16+
width = SV.PAL_XMAX
17+
height = SV.PAL_YMAX
18+
framefreq = 25
19+
else:
20+
width = SV.NTSC_XMAX
21+
height = SV.NTSC_YMAX
22+
framefreq = 30
23+
24+
# Allow resizing window if capturing RGB frames, which can be scaled
25+
if format == SV.RGB8_FRAMES:
26+
gl.keepaspect(width, height)
27+
gl.maxsize(width, height)
28+
gl.stepunit(8, 6)
29+
gl.minsize(120, 90)
30+
else:
31+
if format == SV.YUV411_FRAMES_AND_BLANKING_BUFFER:
32+
height = height + SV.BLANKING_BUFFER_SIZE
33+
gl.prefposition(300, 300+width-1, 100, 100+height-1)
34+
35+
# Open the window
36+
gl.foreground()
37+
win = gl.winopen('Continuous Capture')
38+
gl.RGBmode()
39+
gl.gconfig()
40+
if format == SV.RGB8_FRAMES:
41+
width, height = gl.getsize()
42+
gl.pixmode(GL.PM_SIZE, 8)
43+
else:
44+
gl.pixmode(GL.PM_SIZE, 32)
45+
46+
svci = (format, width, height, queuesize, samplingrate)
47+
[svci]
48+
49+
svci = v.InitContinuousCapture(svci)
50+
width, height = svci[1:3]
51+
[svci]
52+
53+
hz = gl.getgdesc(GL.GD_TIMERHZ)
54+
gl.noise(DEVICE.TIMER0, hz / framerate)
55+
gl.qdevice(DEVICE.TIMER0)
56+
gl.qdevice(DEVICE.WINQUIT)
57+
gl.qdevice(DEVICE.WINSHUT)
58+
gl.qdevice(DEVICE.ESCKEY)
59+
60+
ndisplayed = 0
61+
lastfieldID = 0
62+
63+
while 1:
64+
dev, val = gl.qread()
65+
if dev == DEVICE.REDRAW:
66+
oldw = width
67+
oldh = height
68+
width, height = gl.getsize()
69+
if oldw != width or oldh != height:
70+
v.EndContinuousCapture()
71+
gl.viewport(0, width-1, 0, height-1)
72+
svci = (svci[0], width, height) + svci[3:]
73+
svci = v.InitContinuousCapture(svci)
74+
width, height = svci[1:3]
75+
[svci]
76+
if ndisplayed:
77+
print 'lost',
78+
print fieldID/(svci[4]*2) - ndisplayed,
79+
print 'frames'
80+
ndisplayed = 0
81+
elif dev == DEVICE.TIMER0:
82+
try:
83+
captureData, fieldID = v.GetCaptureData()
84+
except RuntimeError, val:
85+
if val <> 'no data available':
86+
print val
87+
continue
88+
if fieldID - lastfieldID <> 2*samplingrate:
89+
print lastfieldID, fieldID
90+
lastfieldID = fieldID
91+
if svci[0] == SV.RGB8_FRAMES:
92+
rgbbuf = captureData.InterleaveFields(1)
93+
else:
94+
rgbbuf = captureData.YUVtoRGB(1)
95+
captureData.UnlockCaptureData()
96+
gl.lrectwrite(0, 0, width-1, height-1, rgbbuf)
97+
ndisplayed = ndisplayed + 1
98+
elif dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT):
99+
v.EndContinuousCapture()
100+
v.CloseVideo()
101+
gl.winclose(win)
102+
print fieldID, ndisplayed, svci[4]
103+
print 'lost', fieldID/(svci[4]*2) - ndisplayed,
104+
print 'frames'
105+
return
106+
107+
main()

Demo/sgi/sv/rgbgrab.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import sys
2+
import sv, SV
3+
import gl, GL, DEVICE
4+
import time
5+
6+
def main():
7+
v = sv.OpenVideo()
8+
# Determine maximum window size based on signal standard
9+
param = [SV.BROADCAST, 0]
10+
v.GetParam(param)
11+
if param[1] == SV.PAL:
12+
width = SV.PAL_XMAX
13+
height = SV.PAL_YMAX
14+
elif param[1] == SV.NTSC:
15+
width = SV.NTSC_XMAX
16+
height = SV.NTSC_YMAX
17+
else:
18+
print 'Unknown video standard', param[1]
19+
sys.exit(1)
20+
21+
# Initially all windows are half size
22+
grabwidth, grabheight = width/2, height/2
23+
24+
# Open still window
25+
gl.foreground()
26+
gl.prefsize(grabwidth, grabheight)
27+
still_win = gl.winopen('Grabbed frame')
28+
gl.keepaspect(width, height)
29+
gl.maxsize(width, height)
30+
gl.winconstraints()
31+
gl.RGBmode()
32+
gl.gconfig()
33+
gl.clear()
34+
gl.pixmode(GL.PM_SIZE, 8)
35+
36+
# Open live window
37+
gl.foreground()
38+
gl.prefsize(grabwidth, grabheight)
39+
live_win = gl.winopen('Live video')
40+
gl.keepaspect(width, height)
41+
gl.maxsize(width, height)
42+
gl.winconstraints()
43+
44+
# Bind live video
45+
v.SetSize(gl.getsize())
46+
v.BindGLWindow(live_win, SV.IN_REPLACE)
47+
48+
print 'Use leftmouse to grab frame'
49+
50+
gl.qdevice(DEVICE.LEFTMOUSE)
51+
gl.qdevice(DEVICE.WINQUIT)
52+
gl.qdevice(DEVICE.WINSHUT)
53+
gl.qdevice(DEVICE.ESCKEY)
54+
frame = None
55+
while 1:
56+
dev, val = gl.qread()
57+
if dev == DEVICE.LEFTMOUSE and val == 0:
58+
w, h, fields = v.CaptureOneFrame(SV.RGB8_FRAMES, \
59+
grabwidth, grabheight)
60+
frame = sv.InterleaveFields(1, fields, w, h)
61+
gl.winset(still_win)
62+
gl.lrectwrite(0, 0, w - 1, h - 1, frame)
63+
gl.winset(live_win)
64+
if dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT):
65+
v.CloseVideo()
66+
gl.winclose(live_win)
67+
gl.winclose(still_win)
68+
break
69+
if dev == DEVICE.REDRAW and val == still_win:
70+
gl.winset(still_win)
71+
gl.reshapeviewport()
72+
gl.clear()
73+
grabwidth, grabheight = gl.getsize()
74+
if frame:
75+
gl.lrectwrite(0, 0, w - 1, h - 1, frame)
76+
gl.winset(live_win)
77+
if dev == DEVICE.REDRAW and val == live_win:
78+
v.SetSize(gl.getsize())
79+
v.BindGLWindow(live_win, SV.IN_REPLACE)
80+
81+
main()

Demo/sgi/sv/simpleinput.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import sv, SV
2+
import gl, DEVICE
3+
4+
def main():
5+
gl.foreground()
6+
gl.prefsize(SV.PAL_XMAX, SV.PAL_YMAX)
7+
win = gl.winopen('video test')
8+
v = sv.OpenVideo()
9+
params = [SV.VIDEO_MODE, SV.COMP, SV.BROADCAST, SV.PAL]
10+
v.SetParam(params)
11+
v.BindGLWindow(win, SV.IN_REPLACE)
12+
gl.qdevice(DEVICE.ESCKEY)
13+
gl.qdevice(DEVICE.WINQUIT)
14+
gl.qdevice(DEVICE.WINSHUT)
15+
while 1:
16+
dev, val = gl.qread()
17+
if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
18+
v.CloseVideo()
19+
gl.winclose(win)
20+
return
21+
22+
main()

0 commit comments

Comments
 (0)