Skip to content

Commit c40462a

Browse files
author
luyishisi
committed
raspi_camera-shipingzhibo
1 parent cb6d765 commit c40462a

File tree

10 files changed

+46
-3
lines changed

10 files changed

+46
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import subprocess
2+
import time
3+
4+
file_number = 0
5+
dir = "/home/pi/images/"
6+
7+
while True:
8+
file_name = dir + format(file_number,"05d")+".jpg"
9+
file_number = file_number + 1
10+
subprocess.call(["raspistill","-w","400","-h","400","-e","jpg","-n","-t","1","-o",file_name])
11+
subprocess.call(["cp","-f",file_name,dir + "live.jpg"])
12+
time.sleep(2)
13+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import tornado.ioloop
2+
import tornado.web
3+
import subprocess
4+
5+
class MainHandler(tornado.web.RequestHandler):
6+
def get(self):
7+
self.write('<! DOCTYPE html><head>'+
8+
'<META HTTP_EQUIV="refresh"' +
9+
'CONTENT="5"></head><body>' +
10+
'<img src="/images/live.jpg"></body>')
11+
class ImageHandler(tornado.web.StaticFileHandler):
12+
def set_extra_headers(self, path):
13+
self.set_header('Cache-Control',
14+
'no-store, no-cache,must-revalidate, max-age=0')
15+
16+
application = tornado.web.Application([
17+
(r"/",MainHandler),
18+
(r"/images/(.*)", ImageHandler,{"path":"/home/pi/images"})])
19+
20+
if __name__== "__main__":
21+
subprocess.Popen(["python","lianxuzhibo.py"])
22+
application.listen(8899)
23+
tornado.ioloop.IOLoop.instance().start()
24+
25+
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
class MainHandler(tornado.web.RequestHandler):
77
def get(self):
8-
subprocess.call(["raspistill", "-w", "200", "-h", "200",
9-
"-e", "-jpg", "-n", "-t", "1", "-o", "/home/pi/images/live.jpg"])
8+
subprocess.call(["raspistill", "-w", "200", "-h", "200","-e", "jpg", "-n", "-t", "1", "-o", "/home/pi/images/live.jpg"])
109
time.sleep(2)
1110
self.write('<! DOCTYPE html><head>'+
1211
'<META HTTP_EQUIV="refresh"' +
@@ -22,6 +21,6 @@ def set_extra_headers(self, path):
2221
(r"/images/(.*)", ImageHandler,{"path":"/home/pi/images"})])
2322

2423
if __name__== "__main__":
25-
application.listen(8888)
24+
application.listen(8889)
2625
tornado.ioloop.IOLoop.instance().start()
2726

raspi_camera/images/zhibo-test.png

39.7 KB
Loading

raspi_camera/raspistill.txt

Whitespace-only changes.

raspi_camera/readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
本文件夹,记录使用树莓派的红外摄像头进行局域网监控的
2+
请忽略test文件夹,使用效果可以看image文件夹,源代码在LAN-jiankong中
3+
4+
运行live-image-server.py可以在本地开一个8899端口,在浏览器中访问http://localhost:8899/则可以看到最新的图片
5+
6+
可以通过查询本地ip,linux下使用ifconfig获取自己的本地ip我的是192.168.1.106则在同一个局域网中可以通过浏览器访http://192.168.1.106:8899从而进行监控。

0 commit comments

Comments
 (0)