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

Skip to content

Commit e17c6c3

Browse files
committed
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!).
1 parent b7e3cc1 commit e17c6c3

2 files changed

Lines changed: 85 additions & 13 deletions

File tree

Demo/sgi/video/Vb.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def main():
3333

3434
StopCapture = 'StopCapture'
3535

36-
formats = ['rgb24', 'rgb8', 'grey8', 'grey4', 'grey2', \
36+
formats = ['rgb8', 'grey8', 'grey4', 'grey2', \
3737
'grey2_dith', 'mono_dith', 'mono_thresh']
3838
formatmap = {'rgb24': 'rgb', 'grey8': 'grey'}
3939

@@ -42,12 +42,12 @@ class VideoBagOfTricks:
4242
def init(self):
4343
formdef = flp.parse_form('VbForm', 'form')
4444
flp.create_full_form(self, formdef)
45+
self.g_stop.hide_object()
4546
self.setdefaults()
4647
self.openvideo()
4748
self.makewindow()
4849
self.bindvideo()
4950
self.capturing = 0
50-
self.b_stop.hide_object()
5151
self.form.show_form(FL.PLACE_SIZE, FL.TRUE, \
5252
'Video Bag Of Tricks')
5353
fl.set_event_call_back(self.do_event)
@@ -223,6 +223,7 @@ def cb_stop(self, *args):
223223

224224
def cb_capture(self, *args):
225225
self.setwatch()
226+
self.g_main.hide_object()
226227
self.cb_file() # Make sure filename is OK
227228
filename = self.in_file.get_input()
228229
format = self.getformat()
@@ -246,6 +247,7 @@ def cb_capture(self, *args):
246247
convertor = imageop.grey2grey4
247248
elif greybits == -2:
248249
convertor = imageop.dither2grey2
250+
mono = (format == 'mono')
249251
vformat = SV.RGB8_FRAMES
250252
qsize = 0
251253
rate = eval(self.in_rate.get_input())
@@ -254,13 +256,12 @@ def cb_capture(self, *args):
254256
tpf = 50
255257
self.video.InitContinuousCapture(info)
256258
self.capturing = 1
259+
self.g_stop.show_object()
257260
self.setarrow()
258-
self.b_stop.show_object()
259261
while 1:
260262
try:
261263
void = fl.check_forms()
262264
except StopCapture:
263-
self.capturing = 0
264265
break
265266
try:
266267
cd, id = self.video.GetCaptureData()
@@ -274,16 +275,27 @@ def cb_capture(self, *args):
274275
t = id*tpf
275276
if convertor:
276277
data = convertor(data, len(data), 1)
277-
## elif mono and monotreshold >= 0:
278-
## data = imageop.grey2mono(data, len(data), 1,\
279-
## monotreshold)
280-
## elif mono:
281-
## data = imageop.dither2mono(data, len(data), 1)
282-
vout.writeframe(t, data, None)
278+
elif mono:
279+
if self.mono_use_thresh:
280+
data = imageop.grey2mono(data, \
281+
len(data), 1,\
282+
self.mono_thresh)
283+
else:
284+
data = imageop.dither2mono(data, \
285+
len(data), 1)
286+
try:
287+
vout.writeframe(t, data, None)
288+
except IOError, msg:
289+
if msg == (0, 'Error 0'):
290+
msg = 'disk full??'
291+
fl.show_message('IOError: ' + str(msg))
292+
break
283293
self.setwatch()
294+
self.g_stop.hide_object()
295+
self.capturing = 0
284296
vout.close()
285-
self.b_stop.hide_object()
286297
self.video.EndContinuousCapture()
298+
self.g_main.show_object()
287299
self.setarrow()
288300

289301
def cb_quit(self, *args):

Demo/sgi/video/VbForm.fd

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Number of forms: 1
99
Name: form
1010
Width: 350.000000
1111
Height: 240.000000
12-
Number of Objects: 17
12+
Number of Objects: 21
1313

1414
--------------------
1515
class: 1
@@ -26,6 +26,21 @@ name:
2626
callback:
2727
argument:
2828

29+
--------------------
30+
class: 10000
31+
type: 0
32+
box: 0.000000 0.000000 0.000000 0.000000
33+
boxtype: 0
34+
colors: 0 0
35+
alignment: 4
36+
style: 0
37+
size: 11.000000
38+
lcol: 0
39+
label:
40+
name: g_main
41+
callback:
42+
argument:
43+
2944
--------------------
3045
class: 1
3146
type: 2
@@ -251,10 +266,40 @@ name: c_format
251266
callback: cb_format
252267
argument: 0
253268

269+
--------------------
270+
class: 20000
271+
type: 0
272+
box: 0.000000 0.000000 0.000000 0.000000
273+
boxtype: 0
274+
colors: 0 0
275+
alignment: 4
276+
style: 0
277+
size: 11.000000
278+
lcol: 0
279+
label:
280+
name:
281+
callback:
282+
argument:
283+
284+
--------------------
285+
class: 10000
286+
type: 0
287+
box: 0.000000 0.000000 0.000000 0.000000
288+
boxtype: 0
289+
colors: 0 0
290+
alignment: 4
291+
style: 0
292+
size: 11.000000
293+
lcol: 0
294+
label:
295+
name: g_stop
296+
callback:
297+
argument:
298+
254299
--------------------
255300
class: 11
256301
type: 0
257-
box: 0.000000 0.000000 350.000000 240.000000
302+
box: 10.000000 10.000000 330.000000 220.000000
258303
boxtype: 1
259304
colors: 47 47
260305
alignment: 4
@@ -266,5 +311,20 @@ name: b_stop
266311
callback: cb_stop
267312
argument: 0
268313

314+
--------------------
315+
class: 20000
316+
type: 0
317+
box: 0.000000 0.000000 0.000000 0.000000
318+
boxtype: 0
319+
colors: 0 0
320+
alignment: 4
321+
style: 0
322+
size: 11.000000
323+
lcol: 0
324+
label:
325+
name:
326+
callback:
327+
argument:
328+
269329
==============================
270330
create_the_forms

0 commit comments

Comments
 (0)