Skip to content
Snippets Groups Projects
Commit 1e176a01 authored by Aymeric Chaumont's avatar Aymeric Chaumont
Browse files

minor fixes

parent 461ce76d
Branches
No related tags found
1 merge request!49improve cameras
Pipeline #44427 passed with warnings
...@@ -23,8 +23,7 @@ async def handle_cameras(): ...@@ -23,8 +23,7 @@ async def handle_cameras():
while True: while True:
start_timestamp = time.time() current_date = datetime.now()
current_date = datetime.fromtimestamp(start_timestamp)
weekday, current_time = current_date.weekday(), current_date.time() weekday, current_time = current_date.weekday(), current_date.time()
for restaurant in restaurants: for restaurant in restaurants:
...@@ -54,9 +53,7 @@ async def handle_cameras(): ...@@ -54,9 +53,7 @@ async def handle_cameras():
np.array( np.array(
[treated_img]))), [treated_img]))),
axis=0) axis=0)
pre_pred = time.time()
pred_map = np.squeeze(model.predict(input_image, verbose=0)) pred_map = np.squeeze(model.predict(input_image, verbose=0))
print(time.time() - pre_pred)
count_prediction += np.sum(pred_map) count_prediction += np.sum(pred_map)
for caisse in camera["caisses"]: for caisse in camera["caisses"]:
if np.sum(pred_map[caisse["x1"] // 2:caisse["x2"] // 2, caisse["y1"] // 2:caisse["y2"] // 2]) > 0.5: 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(): ...@@ -65,11 +62,11 @@ async def handle_cameras():
cams_working = False cams_working = False
cap.release() cap.release()
if cams_working: if cams_working and open_checkouts:
waiting_time = timedelta( waiting_time = timedelta(
seconds=restaurant['b_factor'] + seconds=restaurant['b_factor'] +
int(count_prediction * int(count_prediction *
restaurant['a_factor'] / max(open_checkouts, 1))) restaurant['a_factor'] / open_checkouts))
db_record = models.Records( db_record = models.Records(
place=restaurant['restaurant'], place=restaurant['restaurant'],
date=current_date, date=current_date,
...@@ -78,4 +75,4 @@ async def handle_cameras(): ...@@ -78,4 +75,4 @@ async def handle_cameras():
db.add(db_record) db.add(db_record)
db.commit() db.commit()
await manager.broadcast(json.dumps({"type": "data"})) await manager.broadcast(json.dumps({"type": "data"}))
time.sleep(60 - time.time() + start_timestamp) time.sleep(60 - (datetime.now() - current_date).total_seconds())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment