diff --git a/app.py b/app.py index 83e3049..a6b2943 100755 --- a/app.py +++ b/app.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from flask import Flask, redirect, request, render_template, send_from_directory +from flask import Flask, redirect, request, render_template, send_from_directory, jsonify import os from os.path import join import uuid @@ -50,6 +50,14 @@ def preview(id: int): return "Impossible de capturer l'image.", 500 +@app.route("/api/scan-for-calibration/") +def scan_calibration(id: int): + conn = db.get() + db.Object.get_from_id(id, conn) + scanner.scan(join(config.DATA_DIR, id, 'calibration')) + return jsonify(config.LEDS_UUIDS) + + @app.route("/calibration/") def calibration(id: int): conn = db.get() diff --git a/config.py b/config.py index b16d621..0c9d396 100644 --- a/config.py +++ b/config.py @@ -1,2 +1,16 @@ DATA_DIR = 'data' +LEDS_UUIDS = [ + 'ac59350e-3787-46d2-88fa-743c1d34fe86', + '83ab3133-d4de-4a42-99a7-8f8a3f3732ba', + '577d6e72-f518-4d65-af28-f8faf1ca3f5d', + 'ec49a20c-bddd-4614-b828-fa45e01bfb19', + '5c249cce-d2b6-4b56-96c8-5caa43d8f040', + '22d783fb-ae55-4581-a3c6-e010d9d5e9de', + '12cb6a32-04a6-433b-8146-b753b8f1286d', + '461255a3-259a-4291-adc3-2fb736231a04', + '3896662f-9826-4445-ad70-86c2e6c143e7', + 'f87698ec-3cba-42fe-9a61-5ac9f77d767a', + '4c77a655-4b68-4557-a696-29345c6676a1', + 'b1cfe287-aa3b-445e-bcdc-75ae375efe43', +] diff --git a/scanner.py b/scanner.py index 00fa2e5..6086c21 100644 --- a/scanner.py +++ b/scanner.py @@ -1,4 +1,7 @@ import cv2 +import os +from os.path import join +from . import config def capture(output_path: str) -> bool: @@ -8,3 +11,12 @@ def capture(output_path: str) -> bool: cv2.imwrite(output_path, img) cam.release() return s + + +def scan(output_dir: str): + os.makedirs(output_dir, exist_ok=True) + for led in config.LEDS_UUIDS: + print(f'Turn on {led}') + img = join(output_dir, led + '.jpg') + capture(img) + print(f'Turn off {led}') diff --git a/templates/calibrate.html b/templates/calibrate.html index 9b37ce6..fb56f98 100644 --- a/templates/calibrate.html +++ b/templates/calibrate.html @@ -4,13 +4,15 @@

Étalonnage

-

Placez la mire devant le scanner puis appuyez sur le bouton pour prévisualiser ou étalonner le scanner.

+
+

Placez la mire devant le scanner puis appuyez sur le bouton pour prévisualiser ou étalonner le scanner.

+
- +
{% endblock content %} @@ -27,23 +32,50 @@ {% block extrajs %} {% endblock extrajs %}