From 28150dd2c4d03ed844e8d1a5cfc463f5d1f9b45f Mon Sep 17 00:00:00 2001 From: Franoosh Date: Tue, 26 May 2026 16:32:13 +0200 Subject: client.cfg : move log dir to /var/log client.py : use ComputingContoursException and DetectMovementException helpers.py : define ComputingContoursException and DetectMovementException clients.html : small changes webserver.py : minor changes worker.py : log disconnectd from web client on debug, not info --- helpers.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'helpers.py') diff --git a/helpers.py b/helpers.py index 8a47415..1ea057b 100644 --- a/helpers.py +++ b/helpers.py @@ -96,15 +96,13 @@ def bytes_to_timestamp(byte_data): def compute_contours(sample_frames): """Compute contours between two frames""" - all_contours = [] frame_0, frame_1 = sample_frames frame_delta = cv2.absdiff(frame_0, frame_1) threshold = cv2.threshold(frame_delta, 25, 255, cv2.THRESH_BINARY)[1] threshold = cv2.dilate(threshold, None, iterations=2) - contours, _ = cv2.findContours(threshold, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) - all_contours.extend(contours) + contours, _ = cv2.findContours(threshold.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) - return all_contours + return contours def scale_contours(contours, scaling_factor): @@ -123,7 +121,7 @@ def scale_contours(contours, scaling_factor): def draw_contours(frame, contours, min_contour_area=500): """Draw contours on the frame.""" for contour in contours: - if cv2.contourArea(contour) > min_contour_area: + if cv2.contourArea(contour) >= min_contour_area: (x, y, w, h) = cv2.boundingRect(contour) cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2) @@ -272,3 +270,9 @@ def auth_service(context, cert_dir): auth.start() auth.configure_curve(location=cert_dir) zmq.auth.load_certificates(cert_dir) + +class ComputingContoursException(Exception): + pass + +class DetectMovementException(Exception): + pass \ No newline at end of file -- cgit v1.3