From 1aa018f7d59e777c461310faa57a7c784f53c9da Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Wed, 17 Jul 2024 22:02:50 +0200 Subject: [PATCH] improved webui --- alpr_api.py | 31 +++++++++++++++++ static/{logo.webp => logo_black.webp} | Bin static/logo_white.webp | Bin 0 -> 3186 bytes static/styles.css | 25 -------------- templates/index.html | 47 +++++++++++++++++++------- 5 files changed, 65 insertions(+), 38 deletions(-) rename static/{logo.webp => logo_black.webp} (100%) create mode 100644 static/logo_white.webp delete mode 100644 static/styles.css diff --git a/alpr_api.py b/alpr_api.py index 8a07908..8d58c9f 100644 --- a/alpr_api.py +++ b/alpr_api.py @@ -137,6 +137,37 @@ def create_rest_server_flask(): result = process_image(image) result = convert_to_cpai_compatible(result) + if len(result['predictions']) == 0: + print("No plate found in the image, trying to split the image") + + width, height = image.size + cell_width = width // 3 + cell_height = height // 3 + + # Define which cells to process (2, 4, 5, 6, 8, 9) + cells_to_process = [2, 4, 5, 6, 8, 9] + + # Loop through each cell + for cell_index in range(1, 10): + # Calculate row and column of the cell + row = (cell_index - 1) // 3 + col = (cell_index - 1) % 3 + + # Calculate bounding box of the cell + left = col * cell_width + upper = row * cell_height + right = left + cell_width + lower = upper + cell_height + + # Check if this cell should be processed + if cell_index in cells_to_process: + # Extract the cell as a new image + cell_image = image.crop((left, upper, right, lower)) + + + + cell_image.show() + return jsonify(result) else: return jsonify({'error': 'Endpoint not implemented'}), 404 diff --git a/static/logo.webp b/static/logo_black.webp similarity index 100% rename from static/logo.webp rename to static/logo_black.webp diff --git a/static/logo_white.webp b/static/logo_white.webp new file mode 100644 index 0000000000000000000000000000000000000000..4b7ed5e2e23307ba1595ec423df1085152489d47 GIT binary patch literal 3186 zcmV-&42|iGmA0Cx;&z=HpaNOBCDukjIk;b zg_-#rZ)ScSZ*`0@nm^90je9efQCJ&e+?!j^Ssi1Ht)0ZoyyR>jV{9#_G&3hzjIp{< zd?bC?ml;KzNKchpYA2FY>m+r+b_g?wagy zn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-0g_owpj_A2O=! z9nm+^e3Gb-{s-jyZXK`9)bg6u6l1n=Ul0KBH|yJHZ)12eG!H%_zOn(M2l*F1D{{&O?xc$AS7n>2%#8DjEJov62HsLeAg4g zopIU0Tn|FzLB!y)d`o9O2-wKwN`~@@u9rsqC>R5tT_r(}N{2{Vem` z6lQT)tNq9~T%;q*sUL@P`%}#5CT={=OQ9f2Kr2+R=Q~2kVh9HVownW7*iC@KCTk>7 z8lK!kCOi|_jz5oo8it@<-&@Ff4JndUC@N5PKmL~N@WV_IC(qJJe{}nxXyFrb)=y!< zzCZxe?OH{h)^3-y9WL)Dr_=25Q;P8YTEwg8)!YzRfIS3_gM2{0+RJB^S3Hm((+~uH zZqfa0BN*B3CZn8hnW@`&wRhCqW}a2){=?KQySt-W9t=ZR<2tfcGrDU)odRdCoLA!Q z%hCp-e_4)xBMwlVILz2&s4j(xer)(@$(9}ea2us`67~XK@em}`G^dz}HqXtfFxGT- zA;+Nl9^BOb+lUn`O#guoC6^2ft2U<=+l+B>VkiolEcQtu%C?r4Z{7|FO0nWH*Qnu4 zxKeQ{@NFxupQTxS#hq$Md=~(GJ?>XBe4E>mRM%`z;OZmCHI?^SJ_0a`17aaYqdIF} zG=^Vej)3Q>MfVpjb+iR(AvjpDEQ+k5?jOWINkB`)?XBePn5rusTnGmYNqRHFvSQ-L zT6@6b{TJ!~z!9~?gwI;8bpFG5`mEKVtLvvGo_B>@Wu|5@|4Y+GD| z^^XMg7(G0Ql3H*xF5_J8iuw|d`$(}b_Eb_IW}U0(jgNM`{SqQ(JVS5MQCS?Iq^aL1 Y6(!I||8T$m_ Image Upload - + - +
- Logo + +
-
-

Upload Image for ALPR

+
+

Upload Image for ALPR

- +
-
- +
-

Response

-

+            

Response

+

         
@@ -68,6 +69,26 @@ } } + // Check for dark mode and switch logo accordingly + const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)"); + function toggleLogo() { + const logo = document.getElementById('logo'); + const logoDark = document.getElementById('logoDark'); + if (prefersDarkScheme.matches) { + logo.style.display = 'none'; + logoDark.style.display = 'block'; + } else { + logo.style.display = 'block'; + logoDark.style.display = 'none'; + } + } + + // Initial call to set logo based on dark mode preference + toggleLogo(); + + // Listen for changes in dark mode preference + prefersDarkScheme.addEventListener('change', toggleLogo); + $(document).ready(function () { $('#uploadForm').on('submit', function (e) { e.preventDefault();