mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Initial revision
This commit is contained in:
		
							parent
							
								
									62f6bc8e55
								
							
						
					
					
						commit
						db96c5a7d9
					
				
					 5 changed files with 262 additions and 0 deletions
				
			
		
							
								
								
									
										9
									
								
								Demo/sgi/sv/README
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Demo/sgi/sv/README
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
Demo programs for the SGI Video library for the Indigo (IRIX 4.0.5).
 | 
			
		||||
These are more-or-less literal translations of the C programs from the
 | 
			
		||||
Indigo Video Programming Guide, by Sjoerd Mullender, with minor
 | 
			
		||||
changes by Guido.
 | 
			
		||||
 | 
			
		||||
simpleinput.py		Live video in a resizable window
 | 
			
		||||
rgbgrab.py		Grab still frames
 | 
			
		||||
contcapt.py		Continuous capturing (to a window)
 | 
			
		||||
burstcapt.py		Burst capturing
 | 
			
		||||
							
								
								
									
										43
									
								
								Demo/sgi/sv/burstcapt.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										43
									
								
								Demo/sgi/sv/burstcapt.py
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
import sv, SV
 | 
			
		||||
import gl, GL, DEVICE
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
	format = SV.RGB8_FRAMES
 | 
			
		||||
	requestedwidth = SV.PAL_XMAX
 | 
			
		||||
	queuesize = 2
 | 
			
		||||
 | 
			
		||||
	v = sv.OpenVideo()
 | 
			
		||||
	svci = (format, requestedwidth, 0, queuesize, 0)
 | 
			
		||||
 | 
			
		||||
	svci, buffer, bitvec = v.CaptureBurst(svci)
 | 
			
		||||
	[bitvec]
 | 
			
		||||
 | 
			
		||||
	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)
 | 
			
		||||
 | 
			
		||||
	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)
 | 
			
		||||
 | 
			
		||||
main()
 | 
			
		||||
							
								
								
									
										107
									
								
								Demo/sgi/sv/contcapt.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										107
									
								
								Demo/sgi/sv/contcapt.py
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,107 @@
 | 
			
		|||
import sys
 | 
			
		||||
import sv, SV
 | 
			
		||||
import gl, GL, DEVICE
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
	format = SV.RGB8_FRAMES
 | 
			
		||||
	framerate = 25
 | 
			
		||||
	queuesize = 16
 | 
			
		||||
	samplingrate = 2
 | 
			
		||||
 | 
			
		||||
	v = sv.OpenVideo()
 | 
			
		||||
	# Determine maximum window size based on signal standard
 | 
			
		||||
	param = [SV.BROADCAST, 0]
 | 
			
		||||
	v.GetParam(param)
 | 
			
		||||
	if param[1] == SV.PAL:
 | 
			
		||||
		width = SV.PAL_XMAX
 | 
			
		||||
		height = SV.PAL_YMAX
 | 
			
		||||
		framefreq = 25
 | 
			
		||||
	else:
 | 
			
		||||
		width = SV.NTSC_XMAX
 | 
			
		||||
		height = SV.NTSC_YMAX
 | 
			
		||||
		framefreq = 30
 | 
			
		||||
 | 
			
		||||
	# Allow resizing window if capturing RGB frames, which can be scaled
 | 
			
		||||
	if format == SV.RGB8_FRAMES:
 | 
			
		||||
		gl.keepaspect(width, height)
 | 
			
		||||
		gl.maxsize(width, height)
 | 
			
		||||
		gl.stepunit(8, 6)
 | 
			
		||||
		gl.minsize(120, 90)
 | 
			
		||||
	else:
 | 
			
		||||
		if format == SV.YUV411_FRAMES_AND_BLANKING_BUFFER:
 | 
			
		||||
			height = height + SV.BLANKING_BUFFER_SIZE
 | 
			
		||||
		gl.prefposition(300, 300+width-1, 100, 100+height-1)
 | 
			
		||||
 | 
			
		||||
	# Open the window
 | 
			
		||||
	gl.foreground()
 | 
			
		||||
	win = gl.winopen('Continuous Capture')
 | 
			
		||||
	gl.RGBmode()
 | 
			
		||||
	gl.gconfig()
 | 
			
		||||
	if format == SV.RGB8_FRAMES:
 | 
			
		||||
		width, height = gl.getsize()
 | 
			
		||||
		gl.pixmode(GL.PM_SIZE, 8)
 | 
			
		||||
	else:
 | 
			
		||||
		gl.pixmode(GL.PM_SIZE, 32)
 | 
			
		||||
 | 
			
		||||
	svci = (format, width, height, queuesize, samplingrate)
 | 
			
		||||
	[svci]
 | 
			
		||||
 | 
			
		||||
	svci = v.InitContinuousCapture(svci)
 | 
			
		||||
	width, height = svci[1:3]
 | 
			
		||||
	[svci]
 | 
			
		||||
 | 
			
		||||
	hz = gl.getgdesc(GL.GD_TIMERHZ)
 | 
			
		||||
	gl.noise(DEVICE.TIMER0, hz / framerate)
 | 
			
		||||
	gl.qdevice(DEVICE.TIMER0)
 | 
			
		||||
	gl.qdevice(DEVICE.WINQUIT)
 | 
			
		||||
	gl.qdevice(DEVICE.WINSHUT)
 | 
			
		||||
	gl.qdevice(DEVICE.ESCKEY)
 | 
			
		||||
 | 
			
		||||
	ndisplayed = 0
 | 
			
		||||
	lastfieldID = 0
 | 
			
		||||
 | 
			
		||||
	while 1:
 | 
			
		||||
		dev, val = gl.qread()
 | 
			
		||||
		if dev == DEVICE.REDRAW:
 | 
			
		||||
			oldw = width
 | 
			
		||||
			oldh = height
 | 
			
		||||
			width, height = gl.getsize()
 | 
			
		||||
			if oldw != width or oldh != height:
 | 
			
		||||
				v.EndContinuousCapture()
 | 
			
		||||
				gl.viewport(0, width-1, 0, height-1)
 | 
			
		||||
				svci = (svci[0], width, height) + svci[3:]
 | 
			
		||||
				svci = v.InitContinuousCapture(svci)
 | 
			
		||||
				width, height = svci[1:3]
 | 
			
		||||
				[svci]
 | 
			
		||||
				if ndisplayed:
 | 
			
		||||
					print 'lost',
 | 
			
		||||
					print fieldID/(svci[4]*2) - ndisplayed,
 | 
			
		||||
					print 'frames'
 | 
			
		||||
				ndisplayed = 0
 | 
			
		||||
		elif dev == DEVICE.TIMER0:
 | 
			
		||||
			try:
 | 
			
		||||
				captureData, fieldID = v.GetCaptureData()
 | 
			
		||||
			except RuntimeError, val:
 | 
			
		||||
				if val <> 'no data available':
 | 
			
		||||
					print val
 | 
			
		||||
				continue
 | 
			
		||||
			if fieldID - lastfieldID <> 2*samplingrate:
 | 
			
		||||
				print lastfieldID, fieldID
 | 
			
		||||
			lastfieldID = fieldID
 | 
			
		||||
			if svci[0] == SV.RGB8_FRAMES:
 | 
			
		||||
				rgbbuf = captureData.InterleaveFields(1)
 | 
			
		||||
			else:
 | 
			
		||||
				rgbbuf = captureData.YUVtoRGB(1)
 | 
			
		||||
			captureData.UnlockCaptureData()
 | 
			
		||||
			gl.lrectwrite(0, 0, width-1, height-1, rgbbuf)
 | 
			
		||||
			ndisplayed = ndisplayed + 1
 | 
			
		||||
		elif dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT):
 | 
			
		||||
			v.EndContinuousCapture()
 | 
			
		||||
			v.CloseVideo()
 | 
			
		||||
			gl.winclose(win)
 | 
			
		||||
			print fieldID, ndisplayed, svci[4]
 | 
			
		||||
			print 'lost', fieldID/(svci[4]*2) - ndisplayed,
 | 
			
		||||
			print 'frames'
 | 
			
		||||
			return
 | 
			
		||||
 | 
			
		||||
main()
 | 
			
		||||
							
								
								
									
										81
									
								
								Demo/sgi/sv/rgbgrab.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										81
									
								
								Demo/sgi/sv/rgbgrab.py
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,81 @@
 | 
			
		|||
import sys
 | 
			
		||||
import sv, SV
 | 
			
		||||
import gl, GL, DEVICE
 | 
			
		||||
import time
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
	v = sv.OpenVideo()
 | 
			
		||||
	# Determine maximum window size based on signal standard
 | 
			
		||||
	param = [SV.BROADCAST, 0]
 | 
			
		||||
	v.GetParam(param)
 | 
			
		||||
	if param[1] == SV.PAL:
 | 
			
		||||
		width = SV.PAL_XMAX
 | 
			
		||||
		height = SV.PAL_YMAX
 | 
			
		||||
	elif param[1] == SV.NTSC:
 | 
			
		||||
		width = SV.NTSC_XMAX
 | 
			
		||||
		height = SV.NTSC_YMAX
 | 
			
		||||
	else:
 | 
			
		||||
		print 'Unknown video standard', param[1]
 | 
			
		||||
		sys.exit(1)
 | 
			
		||||
 | 
			
		||||
	# Initially all windows are half size
 | 
			
		||||
	grabwidth, grabheight = width/2, height/2
 | 
			
		||||
 | 
			
		||||
	# Open still window
 | 
			
		||||
	gl.foreground()
 | 
			
		||||
	gl.prefsize(grabwidth, grabheight)
 | 
			
		||||
	still_win = gl.winopen('Grabbed frame')
 | 
			
		||||
	gl.keepaspect(width, height)
 | 
			
		||||
	gl.maxsize(width, height)
 | 
			
		||||
	gl.winconstraints()
 | 
			
		||||
	gl.RGBmode()
 | 
			
		||||
	gl.gconfig()
 | 
			
		||||
	gl.clear()
 | 
			
		||||
	gl.pixmode(GL.PM_SIZE, 8)
 | 
			
		||||
 | 
			
		||||
	# Open live window
 | 
			
		||||
	gl.foreground()
 | 
			
		||||
	gl.prefsize(grabwidth, grabheight)
 | 
			
		||||
	live_win = gl.winopen('Live video')
 | 
			
		||||
	gl.keepaspect(width, height)
 | 
			
		||||
	gl.maxsize(width, height)
 | 
			
		||||
	gl.winconstraints()
 | 
			
		||||
 | 
			
		||||
	# Bind live video
 | 
			
		||||
	v.SetSize(gl.getsize())
 | 
			
		||||
	v.BindGLWindow(live_win, SV.IN_REPLACE)
 | 
			
		||||
 | 
			
		||||
	print 'Use leftmouse to grab frame'
 | 
			
		||||
 | 
			
		||||
	gl.qdevice(DEVICE.LEFTMOUSE)
 | 
			
		||||
	gl.qdevice(DEVICE.WINQUIT)
 | 
			
		||||
	gl.qdevice(DEVICE.WINSHUT)
 | 
			
		||||
	gl.qdevice(DEVICE.ESCKEY)
 | 
			
		||||
	frame = None
 | 
			
		||||
	while 1:
 | 
			
		||||
		dev, val = gl.qread()
 | 
			
		||||
		if dev == DEVICE.LEFTMOUSE and val == 0:
 | 
			
		||||
			w, h, fields = v.CaptureOneFrame(SV.RGB8_FRAMES, \
 | 
			
		||||
				grabwidth, grabheight)
 | 
			
		||||
			frame = sv.InterleaveFields(1, fields, w, h)
 | 
			
		||||
			gl.winset(still_win)
 | 
			
		||||
			gl.lrectwrite(0, 0, w - 1, h - 1, frame)
 | 
			
		||||
			gl.winset(live_win)
 | 
			
		||||
		if dev in (DEVICE.ESCKEY, DEVICE.WINQUIT, DEVICE.WINSHUT):
 | 
			
		||||
			v.CloseVideo()
 | 
			
		||||
			gl.winclose(live_win)
 | 
			
		||||
			gl.winclose(still_win)
 | 
			
		||||
			break
 | 
			
		||||
		if dev == DEVICE.REDRAW and val == still_win:
 | 
			
		||||
			gl.winset(still_win)
 | 
			
		||||
			gl.reshapeviewport()
 | 
			
		||||
			gl.clear()
 | 
			
		||||
			grabwidth, grabheight = gl.getsize()
 | 
			
		||||
			if frame:
 | 
			
		||||
				gl.lrectwrite(0, 0, w - 1, h - 1, frame)
 | 
			
		||||
			gl.winset(live_win)
 | 
			
		||||
		if dev == DEVICE.REDRAW and val == live_win:
 | 
			
		||||
			v.SetSize(gl.getsize())
 | 
			
		||||
			v.BindGLWindow(live_win, SV.IN_REPLACE)
 | 
			
		||||
 | 
			
		||||
main()
 | 
			
		||||
							
								
								
									
										22
									
								
								Demo/sgi/sv/simpleinput.py
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										22
									
								
								Demo/sgi/sv/simpleinput.py
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,22 @@
 | 
			
		|||
import sv, SV
 | 
			
		||||
import gl, DEVICE
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
main()
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue