otamapy是otama的Python接口。
项目描述
关于
otamapy是otama (otama是CBIR)的Python接口。
安装
通过pip
$ pip install --upgrade otamapy
通过easy_install
$ easy_install -ZU otamapy
需求
安装otama
在MacOSX上
$ sh tools/install-libotama-for-macosx.sh
在Linux上
$ sh tools/install-libotama.sh
用法
配置文件(example.conf)
{
'namespace': 'testnamespace',
'driver': {'name': 'color', 'data_dir': './data', 'color_weight': 0.2},
'database': {'driver': 'sqlite3', 'name': './data/store.sqlite3'}
}
存储到数据库,并从数据库中搜索。
# store_and_search.py
from otama import Otama
db = Otama.open('example.conf')
kvs = {}
db.create_table()
for filename in ('foo.jpg', 'bar.jpg'):
kvs[db.insert(filename)] = filename
for result in db.search(10, 'foo.jpg'):
key = result['id']
print("sim=%.3f, file=%s" % (result['similarity'], kvs[key]))
$ python store_and_search.py
sim=1.000, file=foo.jpg
sim=0.969, file=bar.jpg
参见示例。