Skip to content

Commit

Permalink
finish the changes, make sure tests are working
Browse files Browse the repository at this point in the history
  • Loading branch information
jandom committed Jul 27, 2024
1 parent 00e18fb commit b203778
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 19 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ Image: test_draw_64x64.jpeg -> QReader: ('https://github.com/Eric-Canas/QReader'

Note that **QReader** internally uses <a href="https://github.com/NaturalHistoryMuseum/pyzbar" target="_blank">pyzbar</a> as **decoder**. The improved **detection-decoding rate** that **QReader** achieves comes from the combination of different image pre-processing techniques and the <a href="https://github.com/ultralytics/ultralytics" target="_blank">YOLOv8</a> based <a href="https://github.com/Eric-Canas/qrdet" target="_blank">**QR** detector</a> that is able to detect **QR** codes in harder conditions than classical _Computer Vision_ methods.

## Running tests

The tests can be launched via pytest. Make sure you install the test version of the package

```bash
python -m pip install --editable ".[test]"
```

Then, you can run the tests with

```bash
python -m pytest tests/
```

## Benchmark

### Rotation Test
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"qrdet>=2.5",
],
extras_require={
"tests": ["mypy", "pytest"],
"tests": ["mypy", "pytest", "qrcode"],
},
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
Empty file added tests/__init__.py
Empty file.
Empty file added tests/integration/__init__.py
Empty file.
30 changes: 16 additions & 14 deletions main.py → tests/integration/test_qreader.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import os

import cv2
import qrcode
from qrdet import BBOX_XYXY

from qreader import QReader

SAMPLE_IMG = os.path.join(
os.path.dirname(__file__), "documentation", "resources", "test_draw_64x64.jpeg"
)


def utf_errors_test():
import qrcode
def test_utf_errors():

qreader = QReader(model_size="n")
image_path = "my_image.png"
Expand All @@ -26,10 +22,21 @@ def utf_errors_test():
print(f"result = {result[0]}")


def decode_test_set():
def test_decode_test_set():
images = [
os.path.join(os.path.dirname(__file__), "testset", filename)
for filename in os.listdir(os.path.join(os.path.dirname(__file__), "testset"))
os.path.join(
os.path.dirname(__file__),
"..",
"..",
"documentation",
"resources",
filename,
)
for filename in os.listdir(
os.path.join(
os.path.dirname(__file__), "..", "..", "documentation", "resources"
)
)
]
# Initialize QReader
detector = QReader(model_size="n")
Expand All @@ -49,8 +56,3 @@ def decode_test_set():
pass
# decoded_qrs = detector.detect_and_decode(image=img, return_detections=False)
print("-------------------")


if __name__ == "__main__":
utf_errors_test()
# decode_test_set()
Empty file added tests/preformance/__init__.py
Empty file.
14 changes: 10 additions & 4 deletions performance_test.py → tests/preformance/test_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
from qreader import QReader

SAMPLE_IMG_1 = os.path.join(
os.path.dirname(__file__), "documentation", "resources", "64x64.png"
os.path.dirname(__file__), "..", "..", "documentation", "resources", "64x64.png"
)
SAMPLE_IMG_2 = os.path.join(
os.path.dirname(__file__), "documentation", "resources", "512x512.jpeg"
os.path.dirname(__file__), "..", "..", "documentation", "resources", "512x512.jpeg"
)
SAMPLE_IMG_3 = os.path.join(
os.path.dirname(__file__), "documentation", "resources", "1024x1024.jpeg"
os.path.dirname(__file__),
"..",
"..",
"documentation",
"resources",
"1024x1024.jpeg",
)

PERFORMANCE_TEST_IAMGES = {
Expand All @@ -24,7 +29,8 @@
}
RUNS_TO_AVERAGE, WARMUP_ITERATIONS = 5, 5

if __name__ == "__main__":

def test_performance():
results = {}
for shape, img_path in tqdm(PERFORMANCE_TEST_IAMGES.items()):
# Read the image
Expand Down

0 comments on commit b203778

Please sign in to comment.