Skip to content

Commit

Permalink
fix angles
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Shevtsov committed Sep 28, 2023
1 parent 245ef4f commit e52544a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _detect_column_count_and_orientation(self, image: np.ndarray, parameters: Pa
angle = angle if parameters.document_orientation is None else 0
self.logger.info(f"Final orientation angle = {angle}, is_one_column_document = {is_one_column_document}")

rotated_image, result_angle = self.scew_corrector.preprocess(image, {"rotated_angle": angle})
rotated_image, result_angle = self.scew_corrector.preprocess(image, {"orientation_angle": angle})
result_angle = result_angle["rotated_angle"]

if self.config.get("debug_mode"):
Expand Down
5 changes: 3 additions & 2 deletions tests/unit_tests/test_format_pdf_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_scan_rotator(self) -> None:
image = cv2.imread(path)
_, orientation = self.orientation_classifier.predict(image)
angle_predict = self.orientation_classifier.classes[2 + orientation]
rotated, angle = skew_corrector.preprocess(image, {"rotated_angle": angle_predict})
rotated, angle = skew_corrector.preprocess(image, {"orientation_angle": angle_predict})
angle = angle["rotated_angle"]
self.assertAlmostEqual(angle, angles[i], delta=8)

Expand All @@ -49,8 +49,9 @@ def test_scan_orientation(self) -> None:
path = os.path.join(os.path.dirname(__file__), imgs_path[i])
image = cv2.imread(path)
_, angle_predict = self.orientation_classifier.predict(image)
rotated, angle = skew_corrector.preprocess(image, {"rotated_angle": angle_predict})
rotated, angle = skew_corrector.preprocess(image, {"orientation_angle": angle_predict})
angle = angle["rotated_angle"]
print(angle, angles[i])
self.assertTrue(abs(angle - angles[i]) < max_delta)

def test_header_footer_search(self) -> None:
Expand Down

0 comments on commit e52544a

Please sign in to comment.