Skip to content

Commit

Permalink
save img for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
MateoLostanlen committed Jul 20, 2022
1 parent ee813bc commit c3f9812
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions runner/src/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def setup_engine():
latitude = config_data["latitude"]
longitude = config_data["longitude"]
model_path = config_data["model_path"]
save_img_debug = config_data["save_img_debug"]

# Loading pi zeros datas
with open("data/cameras_credentials.json") as json_file:
Expand All @@ -46,7 +47,7 @@ def setup_engine():
model_path=model_path,
)

return engine, cameras_credentials, loop_time
return engine, cameras_credentials, loop_time, save_img_debug


def capture(ip, CAM_USER, CAM_PWD):
Expand All @@ -62,7 +63,7 @@ def capture(ip, CAM_USER, CAM_PWD):
CAM_USER = os.environ.get("CAM_USER")
CAM_PWD = os.environ.get("CAM_PWD")

engine, cameras_credentials, loop_time = setup_engine()
engine, cameras_credentials, loop_time, save_img_debug = setup_engine()

while True:
for ip in cameras_credentials.keys():
Expand All @@ -71,6 +72,12 @@ def capture(ip, CAM_USER, CAM_PWD):
img = capture(ip, CAM_USER, CAM_PWD)
pred = engine.predict(img, ip)

# Save img
if save_img_debug:
file = 'data/' + ip + '/' + time.strftime("%Y%m%d-%H%M%S") + '.jpg'
os.makedirs(os.path.split(file)[0], exist_ok=True)
img.save('data/' + ip + '/.jpg')

time.sleep(max(loop_time - time.time() + start_time, 0))
except Exception:
logging.warning(f"Unable to get image from camera {ip}")

0 comments on commit c3f9812

Please sign in to comment.