Skip to content

Commit 3cc550d

Browse files
committed
some example files which were lying around
1 parent 493ad5f commit 3cc550d

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

examples/test-fps.lua

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env torch
2+
require 'torch'
3+
require 'sys'
4+
require 'camera'
5+
require 'xlua'
6+
7+
op = xlua.OptionParser('%prog [options]')
8+
op:option{'-dev','--device', action='store',dest='devvideo',
9+
help='number of the /dev/video* device from which you want to capture',
10+
default=0}
11+
op:option{'-w','--width', action='store', dest='width',
12+
help='width of frames you want to capture', default=640}
13+
op:option{'-h','--height', action='store', dest='height',
14+
help='height of frames you want to capture', default=480}
15+
op:option{'-r','--fps', action='store', dest='fps',
16+
help='fps at which you want to capture', default=15}
17+
18+
opt, args = op:parse()
19+
op:summarize()
20+
21+
dev = tonumber(opt.devvideo)
22+
width = tonumber(opt.width)
23+
height = tonumber(opt.height)
24+
fps = tonumber(opt.fps)
25+
26+
camera1 = image.Camera{idx=dev,width=width,height=height,fps=fps}
27+
28+
a1 = camera1:forward()
29+
f = 1
30+
31+
while true do
32+
sys.tic()
33+
a1 = camera1:forward()
34+
f = f + 1
35+
print("FPS: ".. 1/sys.toc())
36+
end

examples/test-hex.lua

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ while true do
3838
frame:narrow(3,320*4,320):copy(a1)
3939
image.display{win=win,image=frame}
4040
image.savePNG(string.format("%s/frame_%05d.png",dir,f),frame)
41+
for i = 1,5 do
42+
image.savePNG(string.format("%s/frame_%05d_%d.png",dir,f,i),frame)
43+
end
4144
f = f + 1
4245
print("FPS: ".. 1/sys.toc())
4346
end

0 commit comments

Comments
 (0)