Skip to content

Commit

Permalink
(qr) no need to calc image size
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh committed May 7, 2024
1 parent 72be897 commit 2a7eb01
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions hmi/scripts/qr_code_decoder
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2a7eb01

Please sign in to comment.