/
pi-motion-lite_5.py
48 lines (39 loc) · 963 Bytes
/
pi-motion-lite_5.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
import Motion
import picamera
import queue
import logging
import threading
fmt = '%(asctime)-15s %(threadName)-8s %(message)s'
logging.basicConfig(
level=logging.DEBUG,
format=fmt,
)
def setupCamera(c):
c.annotate_background = picamera.color.Color('#000') # black
pass
if __name__ == '__main__':
Q = queue.Queue()
writer = Motion.Writer(
Q=Q,
)
writeThread = threading.Thread(
target=writer.writeOut,
daemon=True,
name='Writer',
)
writeThread.start()
with picamera.PiCamera() as camera:
m = Motion.Motion(
camera=camera,
Q=Q,
)
setupCamera(camera)
camThread = threading.Thread(
target=m.run,
daemon=True,
name='Motion',
)
camThread.start()
## won't ever join, so blocks forever
camThread.join()
writeThread.join()