-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_cam.rb
More file actions
29 lines (25 loc) · 798 Bytes
/
simple_cam.rb
File metadata and controls
29 lines (25 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require "date"
fork do
`python -m SimpleHTTPServer`
end
seconds_between_shots = 60
numshots = 10
shots = 0.upto(numshots).map{|i| nil}
currshot = 0
while true do
filename = "shots/#{DateTime.now.to_s}.jpg"
shots[currshot] = filename
`fswebcam -r 640x480 --set brightness=100% #{filename}`
outfile = File::open("index.html", "w")
outfile.write("<html><head><title>Stupid webcam tricks</title></head>\n")
outfile.write("<body\n")
0.upto(numshots).each do |idx|
currfile = shots[(currshot + numshots - idx) % numshots]
outfile.write("\n<img src=\"#{currfile}\"/><br/>\n")
end
outfile.write("<hr/><hr/><a href=\"shots/\">raw image files</a>")
outfile.write("</body></html>")
outfile.close()
sleep seconds_between_shots
currshot = (currshot + 1) % numshots
end