From c169d6d1cf15cc029b67c9588eab9b9792f66c09 Mon Sep 17 00:00:00 2001 From: foefl Date: Tue, 6 Jan 2026 08:06:28 +0100 Subject: [PATCH] change formatting --- src/dopt_sensor_anomalies/detection.py | 29 ++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/dopt_sensor_anomalies/detection.py b/src/dopt_sensor_anomalies/detection.py index 038c8c9..2415541 100644 --- a/src/dopt_sensor_anomalies/detection.py +++ b/src/dopt_sensor_anomalies/detection.py @@ -104,7 +104,7 @@ def measure_length( heightA = np.linalg.norm(tr - br) heightB = np.linalg.norm(tl - bl) - max_height = int(max(heightA, heightB)) + max_height = int(max(heightA, heightB)) if max_width < 100 or max_height < 100: continue @@ -123,16 +123,21 @@ def measure_length( offset = 20 - dst = np.array([ - [offset, offset], - [max_width - 1 + offset, offset], - [max_width - 1 + offset, max_height - 1 + offset], - [offset, max_height - 1 + offset] - ], dtype="float32") - + dst = np.array( + [ + [offset, offset], + [max_width - 1 + offset, offset], + [max_width - 1 + offset, max_height - 1 + offset], + [offset, max_height - 1 + offset], + ], + dtype="float32", + ) + M = cv2.getPerspectiveTransform(box, dst) - warped = cv2.warpPerspective(orig, M, (max_width + 2 * offset, max_height + 2 * offset)) - + warped = cv2.warpPerspective( + orig, M, (max_width + 2 * offset, max_height + 2 * offset) + ) + gray_warped = cv2.cvtColor(warped, cv2.COLOR_BGR2GRAY) _, binary_warped = cv2.threshold(gray_warped, 80, 255, cv2.THRESH_BINARY) pixel_count = np.sum(binary_warped == 0) @@ -141,7 +146,9 @@ def measure_length( [ f"{dimB:.3f}".replace(".", ","), f"{dimA:.3f}".replace(".", ","), - f"{pixel_count / pixels_per_metric_X / pixels_per_metric_Y:.1f}".replace(".", ","), + f"{pixel_count / pixels_per_metric_X / pixels_per_metric_Y:.1f}".replace( + ".", "," + ), ] )