Example #1
0
# load the query image and show it
queryImage = cv2.imread(args["dataset"] + "/" + args["query"])
# cv2.imshow("Query", queryImage)

# print "query: %s" % (args["query"]),'\n<br/>'

# describe the query in the same way that we did in
# index.py -- a 3D RGB histogram with 8 bins per
# channel
desc = RGBHistogram([8, 8, 8])
queryFeatures = desc.describe(queryImage)

# load the index perform the search
#index = cPickle.loads(open(args["index"]).read())
s = SimilarImages()

_index = s.findAll()
index = {}
for i in _index:
    features = i.get('features')
    # print cPickle.loads(features)
    # print cPickle.load(i.get('features'))
    index[i.get('name')] = cPickle.loads(features)
# sys.exit(0) ;
searcher = Searcher(index)
results = searcher.search(queryFeatures)

# initialize the two montages to display our results --
# we have a total of 25 images in the index, but let's only
# display the top 10 results; 5 images per montage, with