Skip to content

Commit

Permalink
Merge pull request #35 from ascribe/fix-orientations
Browse files Browse the repository at this point in the history
* fix orientations search, add test
  • Loading branch information
rhsimplex authored Aug 10, 2016
2 parents a898100 + 1044b6c commit 58481d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion image_match/signature_database_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def search_image(self, path, all_orientations=False, bytestream=False):
# this will only take one iteration
result = []

orientations = np.unique(np.ravel(list(orientations)))
orientations = set(np.ravel(list(orientations)))
for transform in orientations:
# compose all functions and apply on signature
transformed_img = transform(img)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_elasticsearch_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from time import sleep

from image_match.elasticsearch_driver import SignatureES
from PIL import Image

test_img_url1 = 'https://camo.githubusercontent.com/810bdde0a88bc3f8ce70c5d85d8537c37f707abe/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f652f65632f4d6f6e615f4c6973612c5f62795f4c656f6e6172646f5f64615f56696e63692c5f66726f6d5f4332524d465f7265746f75636865642e6a70672f36383770782d4d6f6e615f4c6973612c5f62795f4c656f6e6172646f5f64615f56696e63692c5f66726f6d5f4332524d465f7265746f75636865642e6a7067'
test_img_url2 = 'https://camo.githubusercontent.com/826e23bc3eca041110a5af467671b012606aa406/68747470733a2f2f63322e737461746963666c69636b722e636f6d2f382f373135382f363831343434343939315f303864383264653537655f7a2e6a7067'
Expand Down Expand Up @@ -153,3 +154,14 @@ def test_add_image_with_metadata(ses):
assert 'score' in r[0]
assert 'dist' in r[0]
assert 'id' in r[0]

def test_all_orientations(ses):
im = Image.open('test1.jpg')
im.rotate(90, expand=True).save('rotated_test1.jpg')

ses.add_image('test1.jpg')
sleep(1)
r = ses.search_image('rotated_test1.jpg', all_orientations=True)
assert len(r) == 1
assert r[0]['path'] == 'test1.jpg'
assert r[0]['dist'] < 0.05 # some error from rotation

0 comments on commit 58481d1

Please sign in to comment.