2021-04-03 01:03:52 +08:00
|
|
|
"""Test orientation check and ignore method."""
|
|
|
|
|
|
|
|
import shutil
|
|
|
|
import tempfile
|
|
|
|
|
2021-04-06 20:16:46 +08:00
|
|
|
from mmocr.utils import drop_orientation
|
2021-04-03 01:03:52 +08:00
|
|
|
|
2021-04-06 20:16:46 +08:00
|
|
|
|
|
|
|
def test_drop_orientation():
|
2021-04-03 01:03:52 +08:00
|
|
|
img_file = 'tests/data/test_img2.jpg'
|
2021-04-06 20:16:46 +08:00
|
|
|
output_file = drop_orientation(img_file)
|
2021-04-03 01:03:52 +08:00
|
|
|
assert output_file is img_file
|
|
|
|
|
|
|
|
img_file = 'tests/data/test_img1.jpg'
|
|
|
|
tmp_dir = tempfile.TemporaryDirectory()
|
|
|
|
dst_file = shutil.copy(img_file, tmp_dir.name)
|
2021-04-06 20:16:46 +08:00
|
|
|
output_file = drop_orientation(dst_file)
|
2021-04-03 01:03:52 +08:00
|
|
|
assert output_file[-3:] == 'png'
|