Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
0
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
Esempio n. 6
0
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
Esempio n. 7
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)
Esempio n. 8
0
 def set_cmode(self):
     gl.cmode()
     gl.gconfig()
Esempio n. 9
0
	def set_cmode(self):
		gl.cmode()
		gl.gconfig()
Esempio n. 10
0
	def set_rgbmode(self):
		gl.RGBmode()
		gl.gconfig()
Esempio n. 11
0
import sys
Esempio n. 12
0
import sys
Esempio n. 13
0
import sys
Esempio n. 14
0
# Implement 'jpeg' interface using SGI's compression library
Esempio n. 15
0
 def set_rgbmode(self):
     gl.RGBmode()
     gl.gconfig()
Esempio n. 16
0
import sys
Esempio n. 17
0
# Classes to read and write CMIF video files.
Esempio n. 18
0
# Class to grab frames from a window.
Esempio n. 19
0
import sys
Esempio n. 20
0
# Classes to read and write CMIF video files.