Skip to content

Commit 58481d1

Browse files
authored
Merge pull request #35 from ascribe/fix-orientations
* fix orientations search, add test
2 parents a898100 + 1044b6c commit 58481d1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

image_match/signature_database_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def search_image(self, path, all_orientations=False, bytestream=False):
257257
# this will only take one iteration
258258
result = []
259259

260-
orientations = np.unique(np.ravel(list(orientations)))
260+
orientations = set(np.ravel(list(orientations)))
261261
for transform in orientations:
262262
# compose all functions and apply on signature
263263
transformed_img = transform(img)

tests/test_elasticsearch_driver.py

+12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from time import sleep
77

88
from image_match.elasticsearch_driver import SignatureES
9+
from PIL import Image
910

1011
test_img_url1 = 'https://camo.githubusercontent.com/810bdde0a88bc3f8ce70c5d85d8537c37f707abe/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f652f65632f4d6f6e615f4c6973612c5f62795f4c656f6e6172646f5f64615f56696e63692c5f66726f6d5f4332524d465f7265746f75636865642e6a70672f36383770782d4d6f6e615f4c6973612c5f62795f4c656f6e6172646f5f64615f56696e63692c5f66726f6d5f4332524d465f7265746f75636865642e6a7067'
1112
test_img_url2 = 'https://camo.githubusercontent.com/826e23bc3eca041110a5af467671b012606aa406/68747470733a2f2f63322e737461746963666c69636b722e636f6d2f382f373135382f363831343434343939315f303864383264653537655f7a2e6a7067'
@@ -153,3 +154,14 @@ def test_add_image_with_metadata(ses):
153154
assert 'score' in r[0]
154155
assert 'dist' in r[0]
155156
assert 'id' in r[0]
157+
158+
def test_all_orientations(ses):
159+
im = Image.open('test1.jpg')
160+
im.rotate(90, expand=True).save('rotated_test1.jpg')
161+
162+
ses.add_image('test1.jpg')
163+
sleep(1)
164+
r = ses.search_image('rotated_test1.jpg', all_orientations=True)
165+
assert len(r) == 1
166+
assert r[0]['path'] == 'test1.jpg'
167+
assert r[0]['dist'] < 0.05 # some error from rotation

0 commit comments

Comments
 (0)