From 1e176a01ac18af35894123901059f6f28a962d29 Mon Sep 17 00:00:00 2001
From: Aymeric Chaumont <aymeric.chaumont@student-cs.fr>
Date: Wed, 20 Jul 2022 14:22:42 +0200
Subject: [PATCH] minor fixes

---
 backend/video_capture.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/backend/video_capture.py b/backend/video_capture.py
index a0d537c..7195181 100644
--- a/backend/video_capture.py
+++ b/backend/video_capture.py
@@ -23,8 +23,7 @@ async def handle_cameras():
 
     while True:
 
-        start_timestamp = time.time()
-        current_date = datetime.fromtimestamp(start_timestamp)
+        current_date = datetime.now()
         weekday, current_time = current_date.weekday(), current_date.time()
 
         for restaurant in restaurants:
@@ -54,9 +53,7 @@ async def handle_cameras():
                                     np.array(
                                         [treated_img]))),
                             axis=0)
-                        pre_pred = time.time()
                         pred_map = np.squeeze(model.predict(input_image, verbose=0))
-                        print(time.time() - pre_pred)
                         count_prediction += np.sum(pred_map)
                         for caisse in camera["caisses"]:
                             if np.sum(pred_map[caisse["x1"] // 2:caisse["x2"] // 2, caisse["y1"] // 2:caisse["y2"] // 2]) > 0.5:
@@ -65,11 +62,11 @@ async def handle_cameras():
                         cams_working = False
                     cap.release()
 
-                if cams_working:
+                if cams_working and open_checkouts:
                     waiting_time = timedelta(
                         seconds=restaurant['b_factor'] +
                         int(count_prediction *
-                            restaurant['a_factor'] / max(open_checkouts, 1)))
+                            restaurant['a_factor'] / open_checkouts))
                     db_record = models.Records(
                         place=restaurant['restaurant'],
                         date=current_date,
@@ -78,4 +75,4 @@ async def handle_cameras():
                     db.add(db_record)
                     db.commit()
                     await manager.broadcast(json.dumps({"type": "data"}))
-        time.sleep(60 - time.time() + start_timestamp)
+        time.sleep(60 - (datetime.now() - current_date).total_seconds())
-- 
GitLab