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 0000000..4b7ed5e Binary files /dev/null and b/static/logo_white.webp differ diff --git a/static/styles.css b/static/styles.css deleted file mode 100644 index 686cd2c..0000000 --- a/static/styles.css +++ /dev/null @@ -1,25 +0,0 @@ -body { - font-family: 'Arial', sans-serif; - background-color: #f4f4f9; - margin: 0; - padding: 0; -} - -.container { - background: #fff; - padding: 20px; - border-radius: 10px; - box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); - max-width: 600px; - margin: auto; -} - -h1, h2 { - color: #333; -} - -pre { - background-color: #f8f9fa; - border: 1px solid #ddd; - border-radius: 5px; -} diff --git a/templates/index.html b/templates/index.html index 926f7ab..aa1e433 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,44 +5,45 @@ 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();