mirror of https://github.com/python/cpython
Use groups to show/hide "Stop capture" button.
Made mono capture work. Don't support rgb24 capture (the code for this doesn't exist in Vrec either!).
This commit is contained in:
parent
b7e3cc12e1
commit
e17c6c355a
|
@ -33,7 +33,7 @@ def main():
|
||||||
|
|
||||||
StopCapture = 'StopCapture'
|
StopCapture = 'StopCapture'
|
||||||
|
|
||||||
formats = ['rgb24', 'rgb8', 'grey8', 'grey4', 'grey2', \
|
formats = ['rgb8', 'grey8', 'grey4', 'grey2', \
|
||||||
'grey2_dith', 'mono_dith', 'mono_thresh']
|
'grey2_dith', 'mono_dith', 'mono_thresh']
|
||||||
formatmap = {'rgb24': 'rgb', 'grey8': 'grey'}
|
formatmap = {'rgb24': 'rgb', 'grey8': 'grey'}
|
||||||
|
|
||||||
|
@ -42,12 +42,12 @@ class VideoBagOfTricks:
|
||||||
def init(self):
|
def init(self):
|
||||||
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_stop.hide_object()
|
||||||
self.setdefaults()
|
self.setdefaults()
|
||||||
self.openvideo()
|
self.openvideo()
|
||||||
self.makewindow()
|
self.makewindow()
|
||||||
self.bindvideo()
|
self.bindvideo()
|
||||||
self.capturing = 0
|
self.capturing = 0
|
||||||
self.b_stop.hide_object()
|
|
||||||
self.form.show_form(FL.PLACE_SIZE, FL.TRUE, \
|
self.form.show_form(FL.PLACE_SIZE, FL.TRUE, \
|
||||||
'Video Bag Of Tricks')
|
'Video Bag Of Tricks')
|
||||||
fl.set_event_call_back(self.do_event)
|
fl.set_event_call_back(self.do_event)
|
||||||
|
@ -223,6 +223,7 @@ class VideoBagOfTricks:
|
||||||
|
|
||||||
def cb_capture(self, *args):
|
def cb_capture(self, *args):
|
||||||
self.setwatch()
|
self.setwatch()
|
||||||
|
self.g_main.hide_object()
|
||||||
self.cb_file() # Make sure filename is OK
|
self.cb_file() # Make sure filename is OK
|
||||||
filename = self.in_file.get_input()
|
filename = self.in_file.get_input()
|
||||||
format = self.getformat()
|
format = self.getformat()
|
||||||
|
@ -246,6 +247,7 @@ class VideoBagOfTricks:
|
||||||
convertor = imageop.grey2grey4
|
convertor = imageop.grey2grey4
|
||||||
elif greybits == -2:
|
elif greybits == -2:
|
||||||
convertor = imageop.dither2grey2
|
convertor = imageop.dither2grey2
|
||||||
|
mono = (format == 'mono')
|
||||||
vformat = SV.RGB8_FRAMES
|
vformat = SV.RGB8_FRAMES
|
||||||
qsize = 0
|
qsize = 0
|
||||||
rate = eval(self.in_rate.get_input())
|
rate = eval(self.in_rate.get_input())
|
||||||
|
@ -254,13 +256,12 @@ class VideoBagOfTricks:
|
||||||
tpf = 50
|
tpf = 50
|
||||||
self.video.InitContinuousCapture(info)
|
self.video.InitContinuousCapture(info)
|
||||||
self.capturing = 1
|
self.capturing = 1
|
||||||
|
self.g_stop.show_object()
|
||||||
self.setarrow()
|
self.setarrow()
|
||||||
self.b_stop.show_object()
|
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
void = fl.check_forms()
|
void = fl.check_forms()
|
||||||
except StopCapture:
|
except StopCapture:
|
||||||
self.capturing = 0
|
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
cd, id = self.video.GetCaptureData()
|
cd, id = self.video.GetCaptureData()
|
||||||
|
@ -274,16 +275,27 @@ class VideoBagOfTricks:
|
||||||
t = id*tpf
|
t = id*tpf
|
||||||
if convertor:
|
if convertor:
|
||||||
data = convertor(data, len(data), 1)
|
data = convertor(data, len(data), 1)
|
||||||
## elif mono and monotreshold >= 0:
|
elif mono:
|
||||||
## data = imageop.grey2mono(data, len(data), 1,\
|
if self.mono_use_thresh:
|
||||||
## monotreshold)
|
data = imageop.grey2mono(data, \
|
||||||
## elif mono:
|
len(data), 1,\
|
||||||
## data = imageop.dither2mono(data, len(data), 1)
|
self.mono_thresh)
|
||||||
vout.writeframe(t, data, None)
|
else:
|
||||||
|
data = imageop.dither2mono(data, \
|
||||||
|
len(data), 1)
|
||||||
|
try:
|
||||||
|
vout.writeframe(t, data, None)
|
||||||
|
except IOError, msg:
|
||||||
|
if msg == (0, 'Error 0'):
|
||||||
|
msg = 'disk full??'
|
||||||
|
fl.show_message('IOError: ' + str(msg))
|
||||||
|
break
|
||||||
self.setwatch()
|
self.setwatch()
|
||||||
|
self.g_stop.hide_object()
|
||||||
|
self.capturing = 0
|
||||||
vout.close()
|
vout.close()
|
||||||
self.b_stop.hide_object()
|
|
||||||
self.video.EndContinuousCapture()
|
self.video.EndContinuousCapture()
|
||||||
|
self.g_main.show_object()
|
||||||
self.setarrow()
|
self.setarrow()
|
||||||
|
|
||||||
def cb_quit(self, *args):
|
def cb_quit(self, *args):
|
||||||
|
|
|
@ -9,7 +9,7 @@ Number of forms: 1
|
||||||
Name: form
|
Name: form
|
||||||
Width: 350.000000
|
Width: 350.000000
|
||||||
Height: 240.000000
|
Height: 240.000000
|
||||||
Number of Objects: 17
|
Number of Objects: 21
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
class: 1
|
class: 1
|
||||||
|
@ -26,6 +26,21 @@ name:
|
||||||
callback:
|
callback:
|
||||||
argument:
|
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_main
|
||||||
|
callback:
|
||||||
|
argument:
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
class: 1
|
class: 1
|
||||||
type: 2
|
type: 2
|
||||||
|
@ -251,10 +266,40 @@ name: c_format
|
||||||
callback: cb_format
|
callback: cb_format
|
||||||
argument: 0
|
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_stop
|
||||||
|
callback:
|
||||||
|
argument:
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
class: 11
|
class: 11
|
||||||
type: 0
|
type: 0
|
||||||
box: 0.000000 0.000000 350.000000 240.000000
|
box: 10.000000 10.000000 330.000000 220.000000
|
||||||
boxtype: 1
|
boxtype: 1
|
||||||
colors: 47 47
|
colors: 47 47
|
||||||
alignment: 4
|
alignment: 4
|
||||||
|
@ -266,5 +311,20 @@ name: b_stop
|
||||||
callback: cb_stop
|
callback: cb_stop
|
||||||
argument: 0
|
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:
|
||||||
|
|
||||||
==============================
|
==============================
|
||||||
create_the_forms
|
create_the_forms
|
||||||
|
|
Loading…
Reference in New Issue