Skip to content

Commit 33f9329

Browse files
committed
Fix potential rotation issues when levelling the colour checker.
1 parent 23a5e6b commit 33f9329

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

colour_checker_detection/detection/segmentation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
as_float_array,
4747
as_int_array,
4848
as_int,
49+
orient,
4950
usage_warning,
5051
)
5152
from colour.utilities.documentation import (
@@ -522,10 +523,6 @@ def crop_and_level_image_with_rectangle(
522523
centroid = contour_centroid(cv2.boxPoints(rectangle))
523524
angle = rectangle[-1]
524525

525-
if angle < -45:
526-
angle += 90
527-
width_r, height_r = height_r, width_r
528-
529526
width_r, height_r = as_int_array([width_r, height_r])
530527

531528
M_r = cv2.getRotationMatrix2D(centroid, angle, 1)
@@ -535,6 +532,9 @@ def crop_and_level_image_with_rectangle(
535532
image_r, (width_r, height_r), (centroid[0], centroid[1])
536533
)
537534

535+
if image_c.shape[0] > image_c.shape[1]:
536+
image_c = orient(image_c, "90 CW")
537+
538538
return image_c
539539

540540

0 commit comments

Comments
 (0)