match3d
is essentially a collection of blender scripts for generating views of 3D models, and Python scripts for turning those into something searchable by image-match
.
The most important functionality is provided in api_operations.py
.
from match3d.api_operations import APIOperations
api = APIOperations(index_name='3d_test')
index_name
is the name of the elasticsearch index to use. Defaults to match3d
if none is specified.
You can add a model from URL or local file. You must specify some kind of label either way. Label uniqueness isn麓t enforced (yet), but duplicate labels will be ignored in searches:
api.add('human', stl_url='http://people.sc.fsu.edu/~jburkardt/data/stla/humanoid_tri.stl')
api.add('human_other', stl_url='http://people.sc.fsu.edu/~jburkardt/data/stla/humanoid.stl')
Some more example STL files. For example, download and unzip the Porsche, then:
api.add('porsche', stl_file='/home/ryan/Downloads/porsche.stl')
Search the renderings of different objects and the score of the single best view. Lower numbers are better matches.
api.search(stl_file='/home/ryan/Downloads/porsche.stl')
Gives the result:
{'/home/ryan/Downloads/porsche.stl':
{
u'human_other': 0.44157460914354879,
u'porsche': 0.0
}
}
Or:
api.search('http://people.sc.fsu.edu/~jburkardt/data/stla/humanoid.stl')
gives:
{'http://people.sc.fsu.edu/~jburkardt/data/stla/humanoid.stl':
{
u'human': 0.13292872986279264,
u'human_other': 0.0,
u'porsche': 0.24738691224575407}
}
api.list_designs()
returns
[u'porsche', u'human_other', u'human']