-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch.py
31 lines (25 loc) · 961 Bytes
/
search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from colordescriptor import ColorDescripter
from searcher import Searcher
import argparse
import cv2
# Constructing Argument Parser
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--index", required = True, help = "Path to where the computed index is stored")
ap.add_argument("-q", "--query", required = True, help = "Path to the query image")
ap.add_argument("-r", "--result-path", required = True, help = "Path to the result path")
args = vars(ap.parse_args())
# initializing image descriptor
cd = ColorDescripter((8, 12, 3))
# Load the query image and describe it
query = cv2.imread(args["query"])
features = cd.describe(query)
# Perform the search
searcher = Searcher(args["index"])
results = searcher.search(features)
# Loop over results
for (score, resultID) in results:
# load the result image
result = cv2.imread(args["result_path"] + "/" + resultID)
# Display the Result image
cv2.imshow("Result", result)
cv2.waitKey(0)