Commit c2d58087 authored by Jack Jansen's avatar Jack Jansen

Added 24 bit RGB capture

Added JPEG capture
Added multiple-speed VCR sync and single-step VCR sync
VCR sync recorded movies get correct timestamps
Added (still non-functional) 24-bit picture scaling
parent 6e1adf4a
...@@ -45,9 +45,9 @@ def main(): ...@@ -45,9 +45,9 @@ def main():
StopCapture = 'StopCapture' StopCapture = 'StopCapture'
VideoFormatLabels = ['Video off', 'rgb8', 'grey8', 'grey4', 'grey2', \ VideoFormatLabels = ['Video off', 'rgb8', 'grey8', 'grey4', 'grey2', \
'grey2 dith', 'mono dith', 'mono thresh'] 'grey2 dith', 'mono dith', 'mono thresh', 'rgb24', 'rgb24-jpeg']
VideoFormats = ['', 'rgb8', 'grey', 'grey4', 'grey2', \ VideoFormats = ['', 'rgb8', 'grey', 'grey4', 'grey2', \
'grey2', 'mono', 'mono'] 'grey2', 'mono', 'mono', 'rgb', 'jpeg']
VideoModeLabels = ['Continuous', 'Burst', 'Single frame', 'VCR sync'] VideoModeLabels = ['Continuous', 'Burst', 'Single frame', 'VCR sync']
[VM_CONT, VM_BURST, VM_SINGLE, VM_VCR] = range(1, 5) [VM_CONT, VM_BURST, VM_SINGLE, VM_VCR] = range(1, 5)
...@@ -56,11 +56,17 @@ AudioFormatLabels = ['Audio off', \ ...@@ -56,11 +56,17 @@ AudioFormatLabels = ['Audio off', \
'16 bit mono', '16 bit stereo', '8 bit mono', '8 bit stereo'] '16 bit mono', '16 bit stereo', '8 bit mono', '8 bit stereo']
[A_OFF, A_16_MONO, A_16_STEREO, A_8_MONO, A_8_STEREO] = range(1, 6) [A_OFF, A_16_MONO, A_16_STEREO, A_8_MONO, A_8_STEREO] = range(1, 6)
VcrSpeedLabels = ['normal', '1/3', '1/5', '1/10', '1/30', 'single-step']
VcrSpeeds = [None, 5, 4, 3, 2, 1, 0]
RgbSizeLabels = ['full', 'quarter', 'sixteenth']
class VideoBagOfTricks: class VideoBagOfTricks:
# Init/close stuff # Init/close stuff
def init(self): def init(self):
self.window = None
formdef = flp.parse_form('VbForm', 'form') formdef = flp.parse_form('VbForm', 'form')
flp.create_full_form(self, formdef) flp.create_full_form(self, formdef)
self.g_cont.hide_object() self.g_cont.hide_object()
...@@ -119,6 +125,15 @@ class VideoBagOfTricks: ...@@ -119,6 +125,15 @@ class VideoBagOfTricks:
self.in_nframes.set_input('0') self.in_nframes.set_input('0')
self.in_nframes_vcr.set_input('1') self.in_nframes_vcr.set_input('1')
self.in_rate_vcr.set_input('1') self.in_rate_vcr.set_input('1')
self.c_vcrspeed.clear_choice()
for label in VcrSpeedLabels:
self.c_vcrspeed.addto_choice(label)
self.c_vcrspeed.set_choice(4)
self.c_rgb24_size.clear_choice()
for label in RgbSizeLabels:
self.c_rgb24_size.addto_choice(label)
self.c_rgb24_size.set_choice(1)
self.rgb24_size = 1
# Audio defaults # Audio defaults
self.aout = None self.aout = None
self.aport = None self.aport = None
...@@ -174,6 +189,17 @@ class VideoBagOfTricks: ...@@ -174,6 +189,17 @@ class VideoBagOfTricks:
gl.qdevice(DEVICE.WINQUIT) gl.qdevice(DEVICE.WINQUIT)
gl.qdevice(DEVICE.WINSHUT) gl.qdevice(DEVICE.WINSHUT)
def optfullsizewindow(self):
if not self.window:
return
gl.winset(self.window)
if not self.use_24:
gl.winconstraints()
return
gl.prefsize(self.maxx, self.maxy)
gl.winconstraints()
self.bindvideo()
def bindvideo(self): def bindvideo(self):
if not self.video: return if not self.video: return
x, y = gl.getsize() x, y = gl.getsize()
...@@ -287,6 +313,14 @@ class VideoBagOfTricks: ...@@ -287,6 +313,14 @@ class VideoBagOfTricks:
def cb_rate_vcr(self, *args): def cb_rate_vcr(self, *args):
pass pass
def cb_vcrspeed(self, *args):
pass
def cb_rgb24_size(self, *args):
i = self.c_rgb24_size.get_choice()
if i:
self.rgb24_size = i
# Audio controls: format, file # Audio controls: format, file
def cb_aformat(self, *args): def cb_aformat(self, *args):
...@@ -318,7 +352,7 @@ class VideoBagOfTricks: ...@@ -318,7 +352,7 @@ class VideoBagOfTricks:
elif self.vmode == VM_BURST: elif self.vmode == VM_BURST:
self.burst_capture() self.burst_capture()
elif self.vmode == VM_SINGLE: elif self.vmode == VM_SINGLE:
self.single_capture() self.single_capture(None, None)
elif self.vmode == VM_VCR: elif self.vmode == VM_VCR:
self.vcr_capture() self.vcr_capture()
...@@ -338,6 +372,9 @@ class VideoBagOfTricks: ...@@ -338,6 +372,9 @@ class VideoBagOfTricks:
self.setwatch() self.setwatch()
gl.winset(self.window) gl.winset(self.window)
x, y = gl.getsize() x, y = gl.getsize()
if self.use_24:
fl.show_message('Sorry, no 24 bit continuous capture yet', '', '')
return
vformat = SV.RGB8_FRAMES vformat = SV.RGB8_FRAMES
nframes = self.getint(self.in_nframes, 0) nframes = self.getint(self.in_nframes, 0)
if nframes == 0: if nframes == 0:
...@@ -424,7 +461,7 @@ class VideoBagOfTricks: ...@@ -424,7 +461,7 @@ class VideoBagOfTricks:
self.reset() self.reset()
self.b_capture.label = saved_label self.b_capture.label = saved_label
def single_capture(self): def single_capture(self, stepfunc, timecode):
self.open_if_closed() self.open_if_closed()
self.init_cont() self.init_cont()
while 1: while 1:
...@@ -434,11 +471,32 @@ class VideoBagOfTricks: ...@@ -434,11 +471,32 @@ class VideoBagOfTricks:
except sv.error: except sv.error:
pass pass
sgi.nap(1) sgi.nap(1)
data = cd.InterleaveFields(1) if stepfunc: # This might step the video
d=stepfunc() # to the next frame
if not self.use_24:
data = cd.InterleaveFields(1)
else:
x, y = self.vout.getsize()
if self.rgb24_size == 1:
data = cd.YUVtoRGB(1)
elif self.rgb24_size == 2:
data = cd.YUVtoRGB_quarter(1)
x = x/2
y = y/2
elif self.rgb24_size == 3:
data = cd.YUVtoRGB_sixteenth(1)
x = x/4
y = y/4
else:
raise 'Kaboo! Kaboo!'
if self.use_jpeg:
import jpeg
data = jpeg.compress(data, x, y, 4)
cd.UnlockCaptureData() cd.UnlockCaptureData()
self.end_cont() self.end_cont()
t = (self.nframes+1) * (1000/25) if timecode == None:
return self.write_frame(t, data) timecode = (self.nframes+1) * (1000/25)
return self.write_frame(timecode, data)
def vcr_capture(self): def vcr_capture(self):
if not self.vcr: if not self.vcr:
...@@ -462,9 +520,15 @@ class VideoBagOfTricks: ...@@ -462,9 +520,15 @@ class VideoBagOfTricks:
self.open_if_closed() self.open_if_closed()
rate = self.getint(self.in_rate_vcr, 1) rate = self.getint(self.in_rate_vcr, 1)
rate = max(rate, 1) rate = max(rate, 1)
vcrspeed = self.c_vcrspeed.get_choice()
vcrspeed = VcrSpeeds[vcrspeed]
if vcrspeed == 0:
stepfunc = self.vcr.step
else:
stepfunc = None
self.speed_factor = rate self.speed_factor = rate
addr = self.vcr.sense() addr = start_addr = self.vcr.sense()
if not self.single_capture(): if not self.single_capture(None, 0):
return return
print 'captured %02d:%02d:%02d:%02d' % self.vcr.addr2tc(addr) print 'captured %02d:%02d:%02d:%02d' % self.vcr.addr2tc(addr)
count = self.getint(self.in_nframes_vcr, 1) - 1 count = self.getint(self.in_nframes_vcr, 1) - 1
...@@ -477,7 +541,7 @@ class VideoBagOfTricks: ...@@ -477,7 +541,7 @@ class VideoBagOfTricks:
rate = rate - (here - addr) rate = rate - (here - addr)
addr = here addr = here
return return
if not self.vcr.fwdshuttle(2): # one tenth speed if not self.vcr.fwdshuttle(vcrspeed): # one tenth speed
self.vcr_error('fwd shuttle failed') self.vcr_error('fwd shuttle failed')
return return
cycle = 0 cycle = 0
...@@ -494,7 +558,9 @@ class VideoBagOfTricks: ...@@ -494,7 +558,9 @@ class VideoBagOfTricks:
print 'frame' + 's'*(here-addr-1 <> 1) print 'frame' + 's'*(here-addr-1 <> 1)
cycle = (cycle+1) % rate cycle = (cycle+1) % rate
if cycle == 0: if cycle == 0:
if not self.single_capture(): tc = (here-start_addr)*40
if not self.single_capture(stepfunc, \
tc):
break break
print 'captured %02d:%02d:%02d:%02d' \ print 'captured %02d:%02d:%02d:%02d' \
% self.vcr.addr2tc(here) % self.vcr.addr2tc(here)
...@@ -516,7 +582,10 @@ class VideoBagOfTricks: ...@@ -516,7 +582,10 @@ class VideoBagOfTricks:
else: else:
self.rate = 2 self.rate = 2
x, y = self.vout.getsize() x, y = self.vout.getsize()
info = (SV.RGB8_FRAMES, x, y, qsize, self.rate) if self.use_24:
info = (SV.YUV411_FRAMES, x, y, qsize, self.rate)
else:
info = (SV.RGB8_FRAMES, x, y, qsize, self.rate)
info2 = self.video.InitContinuousCapture(info) info2 = self.video.InitContinuousCapture(info)
if info2 <> info: if info2 <> info:
# XXX This is really only debug info # XXX This is really only debug info
...@@ -558,6 +627,13 @@ class VideoBagOfTricks: ...@@ -558,6 +627,13 @@ class VideoBagOfTricks:
self.rgb = (format[:3] == 'rgb') self.rgb = (format[:3] == 'rgb')
self.mono = (format == 'mono') self.mono = (format == 'mono')
self.grey = (format[:4] == 'grey') self.grey = (format[:4] == 'grey')
self.use_24 = (format in ('rgb', 'jpeg'))
# Does not work.... if self.use_24:
if 0:
self.g_rgb24.show_object()
else:
self.g_rgb24.hide_object()
self.use_jpeg = (format == 'jpeg')
self.mono_use_thresh = (label == 'mono thresh') self.mono_use_thresh = (label == 'mono thresh')
s = format[4:] s = format[4:]
if s: if s:
...@@ -576,6 +652,7 @@ class VideoBagOfTricks: ...@@ -576,6 +652,7 @@ class VideoBagOfTricks:
elif self.greybits == -2: elif self.greybits == -2:
convertor = imageop.dither2grey2 convertor = imageop.dither2grey2
self.convertor = convertor self.convertor = convertor
self.optfullsizewindow()
def get_aformat(self): def get_aformat(self):
self.reset() self.reset()
...@@ -597,6 +674,11 @@ class VideoBagOfTricks: ...@@ -597,6 +674,11 @@ class VideoBagOfTricks:
self.close_video() self.close_video()
gl.winset(self.window) gl.winset(self.window)
x, y = gl.getsize() x, y = gl.getsize()
if self.use_24:
if self.rgb24_size == 2:
x, y = x/2, y/2
elif self.rgb24_size == 4:
x, y = x/4, y/4
vout = VFile.VoutFile().init(self.vfile) vout = VFile.VoutFile().init(self.vfile)
vout.setformat(self.vformat) vout.setformat(self.vformat)
vout.setsize(x, y) vout.setsize(x, y)
......
...@@ -9,7 +9,7 @@ Number of forms: 1 ...@@ -9,7 +9,7 @@ Number of forms: 1
Name: form Name: form
Width: 450.000000 Width: 450.000000
Height: 240.000000 Height: 240.000000
Number of Objects: 33 Number of Objects: 37
-------------------- --------------------
class: 1 class: 1
...@@ -239,7 +239,7 @@ argument: ...@@ -239,7 +239,7 @@ argument:
-------------------- --------------------
class: 31 class: 31
type: 2 type: 2
box: 220.000000 170.000000 100.000000 30.000000 box: 220.000000 130.000000 100.000000 30.000000
boxtype: 2 boxtype: 2
colors: 13 5 colors: 13 5
alignment: 0 alignment: 0
...@@ -284,7 +284,7 @@ argument: ...@@ -284,7 +284,7 @@ argument:
-------------------- --------------------
class: 31 class: 31
type: 1 type: 1
box: 220.000000 170.000000 100.000000 30.000000 box: 220.000000 130.000000 100.000000 30.000000
boxtype: 2 boxtype: 2
colors: 13 5 colors: 13 5
alignment: 0 alignment: 0
...@@ -299,7 +299,7 @@ argument: 0 ...@@ -299,7 +299,7 @@ argument: 0
-------------------- --------------------
class: 31 class: 31
type: 2 type: 2
box: 220.000000 110.000000 100.000000 30.000000 box: 220.000000 70.000000 100.000000 30.000000
boxtype: 2 boxtype: 2
colors: 13 5 colors: 13 5
alignment: 0 alignment: 0
...@@ -344,7 +344,7 @@ argument: ...@@ -344,7 +344,7 @@ argument:
-------------------- --------------------
class: 31 class: 31
type: 2 type: 2
box: 250.000000 170.000000 40.000000 30.000000 box: 250.000000 130.000000 40.000000 30.000000
boxtype: 2 boxtype: 2
colors: 13 5 colors: 13 5
alignment: 0 alignment: 0
...@@ -359,7 +359,7 @@ argument: 0 ...@@ -359,7 +359,7 @@ argument: 0
-------------------- --------------------
class: 2 class: 2
type: 0 type: 0
box: 220.000000 170.000000 30.000000 30.000000 box: 220.000000 130.000000 30.000000 30.000000
boxtype: 0 boxtype: 0
colors: 47 47 colors: 47 47
alignment: 2 alignment: 2
...@@ -374,7 +374,7 @@ argument: ...@@ -374,7 +374,7 @@ argument:
-------------------- --------------------
class: 2 class: 2
type: 0 type: 0
box: 290.000000 170.000000 30.000000 30.000000 box: 290.000000 130.000000 30.000000 30.000000
boxtype: 0 boxtype: 0
colors: 47 47 colors: 47 47
alignment: 2 alignment: 2
...@@ -389,7 +389,7 @@ argument: ...@@ -389,7 +389,7 @@ argument:
-------------------- --------------------
class: 13 class: 13
type: 0 type: 0
box: 220.000000 110.000000 100.000000 30.000000 box: 220.000000 70.000000 100.000000 30.000000
boxtype: 0 boxtype: 0
colors: 7 3 colors: 7 3
alignment: 4 alignment: 4
...@@ -451,7 +451,7 @@ class: 10000 ...@@ -451,7 +451,7 @@ class: 10000
type: 0 type: 0
box: 0.000000 0.000000 0.000000 0.000000 box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0 boxtype: 0
colors: 1147496041 1852404841 colors: 640 235
alignment: 4 alignment: 4
style: 0 style: 0
size: 11.000000 size: 11.000000
...@@ -464,7 +464,7 @@ argument: ...@@ -464,7 +464,7 @@ argument:
-------------------- --------------------
class: 31 class: 31
type: 2 type: 2
box: 220.000000 110.000000 100.000000 30.000000 box: 220.000000 70.000000 100.000000 30.000000
boxtype: 2 boxtype: 2
colors: 13 5 colors: 13 5
alignment: 0 alignment: 0
...@@ -479,7 +479,7 @@ argument: 0 ...@@ -479,7 +479,7 @@ argument: 0
-------------------- --------------------
class: 31 class: 31
type: 2 type: 2
box: 220.000000 170.000000 100.000000 30.000000 box: 220.000000 130.000000 100.000000 30.000000
boxtype: 2 boxtype: 2
colors: 13 5 colors: 13 5
alignment: 0 alignment: 0
...@@ -491,12 +491,72 @@ name: in_rate_vcr ...@@ -491,12 +491,72 @@ name: in_rate_vcr
callback: cb_rate_vcr callback: cb_rate_vcr
argument: 0 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 class: 20000
type: 0 type: 0
box: 0.000000 0.000000 0.000000 0.000000 box: 0.000000 0.000000 0.000000 0.000000
boxtype: 0 boxtype: 0
colors: 544171552 1331849829 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 200.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 alignment: 4
style: 0 style: 0
size: 11.000000 size: 11.000000
......
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