From 2a7eb014347af45f5a79e134f352b336d12ed597 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 7 May 2024 18:43:07 +0200 Subject: [PATCH] (qr) no need to calc image size --- hmi/scripts/qr_code_decoder | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hmi/scripts/qr_code_decoder b/hmi/scripts/qr_code_decoder index 94702da..8dbe421 100755 --- a/hmi/scripts/qr_code_decoder +++ b/hmi/scripts/qr_code_decoder @@ -24,13 +24,10 @@ def validate_image(qr_image: ndarray, qr_code_rect: tuple, threshold_percentage: x, y, w, h = qr_code_rect # Coordinates of the bounding box around the QR code # Calculate the area of the QR code - qr_code_area = w * h - - # Calculate the total area of the image - total_image_area = qr_image.shape[0] * qr_image.shape[1] + qr_code_area: int = w * h # Calculate the percentage of the screen occupied by the QR code - qr_code_percentage = (qr_code_area / total_image_area) * 100 + qr_code_percentage = (qr_code_area / qr_image.size) * 100 # Check if the QR code occupies at least threshold_percentage of the screen if qr_code_percentage >= threshold_percentage: