image-match
osakapy 2016.04
15 April 2016
Hideo Hattori
Software Enginner, KLab Inc. (Osaka)
whoami
Hideo Hattori (github(https://github.com/hhatto))
Python / Go / C / Rust / Zsh
My Python Projects autopep8(https://github.com/hhatto/autopep8), pgmagick(https://github.com/hhatto/pgmagick/),
poyonga(https://github.com/hhatto/poyonga), genzshcomp(https://bitbucket.org/hhatto/genzshcomp)...
image-match
image-match
image-match
image-match(https://github.com/ascribe/image-match)
Python2.x only
libpuzzle(https://www.pureftpd.org/project/libpuzzle)
Perceptual Hash
image-match
image-match
$ brew install py2cairo cairo elasticsearch
$ pip install numpy scipy image_match
2
from image_match.goldberg import ImageSignature
gis = ImageSignature()
a = gis.generate_signature('a.jpg')
b = gis.generate_signature('b.jpg')
c = gis.generate_signature('c.jpg')
print("a-b: %f" % gis.normalized_distance(a, b))
print("a-c: %f" % gis.normalized_distance(a, c))
$ python distance.py
a-b: 0.220952
a-c: 0.684463
=
with Elasticsearch
Elasticsearch(https://www.elastic.co/products/elasticsearch)
from elasticsearch import Elasticsearch
from image_match.elasticsearch_driver import SignatureES
es = Elasticsearch()
ses = SignatureES(es)
es = Elasticsearch()
ses = SignatureES(es, size=10, distance_cutoff=0.9)
ses.add_image(filename)
ses.search_image(filename)
{'path': u'image/image_08179.jpg', 'score': 56.06757, 'dist': 0.0, 'id': u'AVQQyhUEJXUmYMIAjxKA'}
{'path': u'image/image_01623.jpg', 'score': 0.2764881, 'dist': 0.55480701966252521, 'id': u'AVQQxa3_JX
{'path': u'image/image_04659.jpg', 'score': 0.33701482, 'dist': 0.56801020853288964, 'id': u'AVQQx7GOJ
otama image-match
otama(https://github.com/nagadomi/otama)
otamapy(https://github.com/hhatto/otamapy)otama Python
http:// owers.libotama.so/
(8189 )(http://www.robots.ox.ac.uk/~vgg/data/ owers/102/)
$ brew tap hhatto/otama
$ brew install otama
$ pip install --upgrade otamapy
image-match
from elasticsearch import Elasticsearch
from image_match.elasticsearch_driver import SignatureES
es = Elasticsearch()
ses = SignatureES(es)
for filename in files:
ses.add_image(filename)
image-match
es = Elasticsearch()
ses = SignatureES(es, size=10, distance_cutoff=0.9)
#for o in ses.search_image(TARGET_FILE, all_orientations=True):
for o in ses.search_image(TARGET_FILE):
print(o)
otama
from otama import Otama
db = Otama.open(config)
db.create_database()
for filename in files:
key = db.insert(filename)
keystore[key] = filename
db.pull()
db.close()
otama
db = Otama(config)
for result in db.search(10, TARGET_FILE):
key = result['id']
print("sim=%.3f, file=%s" % (result['similarity'], keystore[key]))
print(db.exists(key))
otama
otama ( time )
Thank you
Hideo Hattori
Software Enginner, KLab Inc. (Osaka)
@hhatto(http://twitter.com/hhatto)
image-matchの紹介

image-matchの紹介