"--index", required=True, help="Path to where we stored our index") ap.add_argument("-q", "--query", required=True, help="Path to query image") args = vars(ap.parse_args()) queryImage = cv2.imread(args["query"]) cv2.imshow("Query", queryImage) print("query: {}".format(args["query"])) desc = RGBHistogram([8, 8, 8]) queryFeatures = desc.describe(queryImage) index = pickle.loads(open(args["index"], "rb").read()) searcher = Searcher(index) results = searcher.search(queryFeatures) montageA = np.zeros((166 * 5, 400, 3), dtype="uint8") montageB = np.zeros((166 * 5, 400, 3), dtype="uint8") for j in range(0, 10): (score, imageName) = results[j] path = os.path.join(args["dataset"], imageName) result = cv2.imread(path) print("\t{}. {} : {:.3f}".format(j + 1, imageName, score)) if j < 5: montageA[j * 166:(j + 1) * 166, :] = result else: montageB[(j - 5) * 166:((j - 5) + 1) * 166, :] = result
ap.add_argument("-r", "--result-path", required=True, help="Path to the result path") args = vars(ap.parse_args()) # initialize the image descriptor cd = ColorDescriptor((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) print(results) # display the query cv2.imshow("Query", query) query = cv2.resize(query, (400, 400)) results_arr = [] # loop over the results for (score, resultID) in results: # load the result image and display it result = cv2.imread(args["result_path"] + "/" + resultID) result = cv2.resize(result, (400, 400)) results_arr.append(result) #im = cv2.resize(result, (1000, 800)) #imstack = np.hstack(imstack, im)