def index(): SIFT = sift_controller.SIFT() SIFT.dump_onefile() for img_path in glob.glob("./ResizeData/*.jpg"): img_name = img_path.split("/")[-1] SIFT.dump_eachfile(img_name) # if __name__ == "__main__": # # index()
def prefetching(query_path): pkl_file = open("siftdump.pkl", "rb") sift = sift_controller.SIFT() query_img = cv2.imread(query_path, 0) query_des = sift.extract(query_img) input_list = [] for idx, contents in enumerate(pickleloader(pkl_file)): id, indexed_des = parse_pkl(contents) if (indexed_des.all()) == None: continue input_list.append([query_des, id, indexed_des]) del sift pkl_file.close() return input_list
def test(case): correct_num = 0 top_1_correct_num = 0 top_5_correct_num = 0 sift = sift_controller.SIFT() output_file = "noise_{}.txt".format(case) incorrect_txt = open(output_file, "w") forder_path = "./{}/*.jpg".format(case) image_list = glob.glob(forder_path) total_time = 0. for img_path in image_list: start_time = time.time() # case result = sift.search(img_path) end_time = time.time() - start_time total_time += end_time filename = img_path.split("/")[2] gt_label = filename.split("_")[2] top_1_result = [result[0]] top_5_result = result if isCorrect(gt_label, top_1_result): top_1_correct_num += 1 top_5_correct_num += 1 # print ("Correct: {}".format(gt_label)) elif isCorrect(gt_label, top_5_result): top_5_correct_num += 1 else: out_txt = "{} {}\n".format(img_path, ','.join(str(v) for v in result)) # print ("Wrong: {}".format(gt_label)) incorrect_txt.write(out_txt) # print("(top 1) {} : {} / {}".format(case, top_1_correct_num, len(image_list))) print("(top 5) {} : {} / {}".format(case, top_5_correct_num, len(image_list))) # print ("Total time : {}".format(total_time)) incorrect_txt.close()
def extract_feature_eachfile(): sift = sift_controller.SIFT() sift.dump_eachfile() del sift
def Linear_search_prefetching(query_path): sift = sift_controller.SIFT() result = sift.inmemory_search(query_path) del sift return (result)
def Linear_search_by_FLANN(query_path): sift = sift_controller.SIFT() result = sift.fast_search(query_path) del sift return (result)
def Linear_search(query_path): sift = sift_controller.SIFT() result = sift.search(query_path) del sift return (result)
def extract_feature_onedump(): sift = sift_controller.SIFT() sift.dump_onefile() del sift
def Linear_search(query_path): sift = sift_controller.SIFT() result = sift.search(query_path) print("{} {}\n".format(img_path, ','.join(str(v) for v in result))) del sift
def Linear_search(query_path): sift = sift_controller.SIFT() sift.search(query_path) del sift
def Linear_search_by_FLANN(query_path): sift = sift_controller.SIFT() sift.fast_search(query_path) del sift