-
Notifications
You must be signed in to change notification settings - Fork 0
/
counter.py
executable file
·49 lines (43 loc) · 1.2 KB
/
counter.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
49
import os
import RPi.GPIO as io
import time
from picamera import PiCamera
from datetime import datetime
#PIR setup
pir_pin = 17
io.setmode(io.BCM)
io.setup(pir_pin, io.IN)
#camera settings
camera = PiCamera()
camera.exposure_mode = 'auto'
camera.resolution = (680, 480)
camera.awb_mode = 'auto'
def motion(pir_pin):
# print("Motion!")
filename = 'counter_image.jpg'
piclocation = '/home/pi/Public/images/'+ filename
# time.sleep(1)
# camera.start_preview()
# time.sleep(2)
camera.capture(piclocation)
# time.sleep(1)
# camera.stop_preview()
# print("PIR Module test")
# time.sleep(2)
# print("Ready")
while True:
try:
# print ("rpi-ms-camera: Waiting for motion.")
io.wait_for_edge(pir_pin, io.RISING)
motion(pir_pin)
# time.sleep(1)
# print("executing object detection")
# execfile("/home/pi/Public/trail-counter-RPi3-setup/detect.py")
os.system('python3 /home/pi/Public/trail-counter-RPi3-setup/detect.py')
# print ("rpi-ms-camera: Sleeping")
# time.sleep(1)
except KeyboardInterrupt:
# print ("rpi-ms-camera: Stopping due to keyboard interrupt.")
camera.close()
io.cleanup()
break