@@ -10,15 +10,17 @@ require 'xlua'
10
10
require ' torch'
11
11
require ' qt'
12
12
require ' qtwidget'
13
- xrequire (' inline' ,true )
14
- xrequire (' ffmpeg' ,true )
15
- xrequire (' imgraph' ,true )
16
- xrequire (' nnx' ,true )
13
+ require ' inline'
14
+ require ' imgraph'
15
+ require ' nnx'
17
16
18
17
-- parse args
19
18
op = xlua .OptionParser (' %prog [options]' )
19
+ op :option {' -c' , ' --camera' , action = ' store' , dest = ' camidx' ,
20
+ help = ' camera index: /dev/videoIDX (if no video given)' ,
21
+ default = 0 }
20
22
op :option {' -v' , ' --video' , action = ' store' , dest = ' video' ,
21
- help = ' video file to process' , req = true }
23
+ help = ' video file to process' }
22
24
op :option {' -f' , ' --fps' , action = ' store' , dest = ' fps' ,
23
25
help = ' number of frames per second' , default = 10 }
24
26
op :option {' -t' , ' --time' , action = ' store' , dest = ' seconds' ,
@@ -31,9 +33,16 @@ op:option{'-z', '--zoom', action='store', dest='zoom',
31
33
help = ' display zoom' , default = 1 }
32
34
opt ,args = op :parse ()
33
35
34
- -- load video
35
- video = ffmpeg .Video {path = opt .video , width = opt .width , height = opt .height ,
36
- fps = opt .fps , length = opt .seconds , delete = false }
36
+ if not opt .video then
37
+ -- load camera
38
+ require ' camera'
39
+ video = image .Camera (opt .camidx , opt .width , opt .height )
40
+ else
41
+ -- load video
42
+ require ' ffmpeg'
43
+ video = ffmpeg .Video {path = opt .video , width = opt .width , height = opt .height ,
44
+ fps = opt .fps , length = opt .seconds , delete = false }
45
+ end
37
46
38
47
-- setup GUI (external UI file)
39
48
if not win or not widget then
0 commit comments