Skip to content

Commit

Permalink
Adds unit test for single sample ocr with GoogleOCR
Browse files Browse the repository at this point in the history
  • Loading branch information
Paethon committed Nov 2, 2023
1 parent b83e04b commit dfdb037
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The version numbers are according to [Semantic Versioning](http://semver.org/).
### Fixed
- Adds forced conversion to RGB in pillow before sending data to OpenCV to fix a possible bug in Studio
- Fixes a rare bug where self-intersecting bounding boxes caused the OCR system to crash when using multi-pass OCR

### Removed


Expand Down
8 changes: 8 additions & 0 deletions tests/test_googleocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ def unrotated_bboxes(ocr):

def test_google_ocr(ocr):
img = Image.open(os.path.join(DATA_DIR, "ocr_test_big.png"))
res = ocr.ocr(img)
text = " ".join([r["text"] for r in res])
assert text == "This is a test ."
assert all([r["bbox"].original_size == img.size for r in res])


def test_google_orc_single_sample():
img = Image.open(os.path.join(DATA_DIR, "ocr_test_big.png"))
ocr = GoogleOCR(auto_rotate=True, ocr_samples=1)
res = ocr.ocr(img)
text = " ".join([r["text"] for r in res])
assert text == "This is a test ."
Expand Down

0 comments on commit dfdb037

Please sign in to comment.