-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebstream_cv.py
48 lines (45 loc) · 1.56 KB
/
webstream_cv.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Part 01 using opencv access webcam and transmit the video in HTML
import cv2
import pyshine as ps # pip3 install pyshine==0.0.9
import numpy as np
import threading
from datetime import datetime
PAGE="""\
<html>
<head>
<style>
h1{font-weightLbold;font-family:Verdana;color:white;font-size:25px;margin-bottom:10px}
body{background-color:lightblue}
img{border:white solid 5px}
#text{color:white;font-family:Verdana;font-weight:bold;font-size:20px}
</style>
<title>Raspberry Pi - Surveillance Camera</title>
</head>
<body>
<center><h1>Raspberry Pi - Surveillance Camera</h1></center>
<center><img src="stream.mjpg" width="960" height="560"></center>
</body>
</html>
"""
def main():
StreamProps = ps.StreamProps
StreamProps.set_Page(StreamProps,PAGE)
address = ('192.168.137.45',8000) # Enter your IP address
try:
StreamProps.set_Mode(StreamProps,'cv2')
capture = cv2.VideoCapture(0)
#detect_fire_function(capture);
capture.set(cv2.CAP_PROP_BUFFERSIZE,4)
capture.set(cv2.CAP_PROP_FRAME_WIDTH,320)
capture.set(cv2.CAP_PROP_FRAME_HEIGHT,240)
capture.set(cv2.CAP_PROP_FPS,30)
StreamProps.set_Capture(StreamProps,capture)
StreamProps.set_Quality(StreamProps,90)
server = ps.Streamer(address,StreamProps)
print('Server started at','http://'+address[0]+':'+str(address[1]))
server.serve_forever()
except KeyboardInterrupt:
capture.release()
server.socket.close()
if __name__=='__main__':
main()