From 9f96b351a51b0880ad6db0f1d76164067dec7af3 Mon Sep 17 00:00:00 2001 From: Lawrence Hudson Date: Thu, 1 Dec 2016 10:34:29 +0000 Subject: [PATCH] [#7] test numpy interface even with cv2 --- pyzbar/tests/test_decode.py | 7 +++++++ requirements.pip | 1 + setup.py | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pyzbar/tests/test_decode.py b/pyzbar/tests/test_decode.py index f71489f..4f8ff25 100644 --- a/pyzbar/tests/test_decode.py +++ b/pyzbar/tests/test_decode.py @@ -3,6 +3,8 @@ from pathlib import Path +import numpy as np + from PIL import Image try: @@ -83,6 +85,11 @@ def test_empty(self): expected = [] self.assertEqual(expected, res) + def test_decode_numpy(self): + "Read image using Pillow and convert to numpy.ndarray" + res = decode(np.asarray(self.code128)) + self.assertEqual(self.EXPECTED_CODE128, res) + @unittest.skipIf(cv2 is None, 'OpenCV not installed') def test_decode_opencv(self): "Read image using OpenCV" diff --git a/requirements.pip b/requirements.pip index 8065285..eb47ae0 100644 --- a/requirements.pip +++ b/requirements.pip @@ -4,5 +4,6 @@ enum34==1.1.6; python_version == '2.7' # TODO How to specify OpenCV? 'cv2>=2.4.8' coveralls>=1.1 nose>=1.3.4 +numpy>=1.8.2 pathlib>=1.0.1; python_version == '2.7' Pillow>=3.2.0 diff --git a/setup.py b/setup.py index 8751d30..e0da3f6 100755 --- a/setup.py +++ b/setup.py @@ -45,7 +45,8 @@ def readme(): }, 'tests_require': [ # TODO How to specify OpenCV? 'cv2>=2.4.8', - PILLOW + PILLOW, + 'numpy>=1.8.2', ], 'include_package_data': True, 'classifiers': [