diff --git a/backend/video_capture.py b/backend/video_capture.py index a0d537ce4cc5fd2bd029e64f19d57d8a8bdc298b..7195181a813939697507cad9fbe990354a38d058 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())