fix: swap 90°/270° rotation direction in orientation detection
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 27s
CI / test-go-edu-search (push) Successful in 30s
CI / test-python-klausur (push) Failing after 1m56s
CI / test-python-agent-core (push) Successful in 17s
CI / test-nodejs-website (push) Successful in 18s
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 27s
CI / test-go-edu-search (push) Successful in 30s
CI / test-python-klausur (push) Failing after 1m56s
CI / test-python-agent-core (push) Successful in 17s
CI / test-nodejs-website (push) Successful in 18s
Tesseract OSD 'rotate' returns the clockwise correction needed, but the code was applying counterclockwise for 90° and clockwise for 270° — exactly reversed. This caused pages scanned sideways to be flipped upside down instead of corrected. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -113,13 +113,13 @@ def detect_and_fix_orientation(img_bgr: np.ndarray) -> Tuple[np.ndarray, int]:
|
||||
if rotate == 0 or confidence < 1.0:
|
||||
return img_bgr, 0
|
||||
|
||||
# Apply rotation
|
||||
# Apply rotation — OSD rotate is the clockwise correction needed
|
||||
if rotate == 180:
|
||||
corrected = cv2.rotate(img_bgr, cv2.ROTATE_180)
|
||||
elif rotate == 90:
|
||||
corrected = cv2.rotate(img_bgr, cv2.ROTATE_90_COUNTERCLOCKWISE)
|
||||
elif rotate == 270:
|
||||
corrected = cv2.rotate(img_bgr, cv2.ROTATE_90_CLOCKWISE)
|
||||
elif rotate == 270:
|
||||
corrected = cv2.rotate(img_bgr, cv2.ROTATE_90_COUNTERCLOCKWISE)
|
||||
else:
|
||||
return img_bgr, 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user