systemd files, documentation and a bug fix
Change-Id: I66e34059e0c1d604b82fba558bfeadee2ace093c
diff --git a/person_detection/base_camera.py b/person_detection/base_camera.py
index 53525ab..e2e85b6 100644
--- a/person_detection/base_camera.py
+++ b/person_detection/base_camera.py
@@ -1,12 +1,8 @@
import paho.mqtt.client as mqtt
import time
-import os
-import sys
import threading
import logging as log
-from multiprocessing import Process, Queue, Value, Array, Lock
-import threading
-from collections import defaultdict
+from multiprocessing import Process, Queue, Value, Lock
from roc import Roc
import config
@@ -79,8 +75,8 @@
self.mbrhigh = mbrhigh
self.devicegroup = devicegroup
self.noroc = noroc
- self.roc = Roc(user, password)
+ self.roc = Roc(config.url, user, password, config.enterprise, config.site)
"""Start the background camera process if it isn't running yet."""
if BaseCamera.cameras[int(self.device)] == 0:
@@ -115,14 +111,12 @@
BaseCamera.event[self.device].set() # send signal to clients
time.sleep(0)
-
def _process(self):
"""Camera background process."""
frames_iterator = self.frames()
for frame in frames_iterator:
BaseCamera.deviceQ[self.device].put(frame, block=True)
-
def person_detected(self, num):
self.last_detected = time.time()
if not self.detected:
@@ -139,7 +133,7 @@
self.detected = False
self.timer = None
BaseCamera.lock.acquire()
- BaseCamera.activity_counter.value -=1
+ BaseCamera.activity_counter.value -= 1
if BaseCamera.activity_counter.value <= 0:
BaseCamera.activity_counter.value = 0
self.set_resolution_low()
@@ -147,30 +141,25 @@
self.roc.set_mbr(self.devicegroup, self.mbrlow)
BaseCamera.lock.release()
-
def start_timer(self):
# log.info("Start timer for device {}".format(device))
self.timer = threading.Timer(10.0, self.timer_expiry)
self.timer.start()
-
def set_resolution_high(self):
for device in range(0, len(config.cameras)):
self.set_resolution(str(device), "high")
-
def set_resolution_low(self):
for device in range(0, len(config.cameras)):
self.set_resolution(str(device), "low")
-
def set_resolution(self, device, level):
log.info("Setting camera {} resolution to {}".format(device, level))
client = mqtt.Client()
client.connect(self.mqttBroker)
client.publish("camera/" + str(5000 + int(device)), level)
-
def timer_expiry(self):
now = time.time()
diff = now - self.last_detected