def confirm1(self): # 确认键的操作 self.current_person_id_cam1 = int(self.entry_id1.get()) self.current_img_id_cam1 = 0 person_id = tools.format_id(self.current_person_id_cam1) bm1 = Image.open(dataset_dir + person_id + "_00.jpg") tkimg1 = ImageTk.PhotoImage(bm1) self.label_person_image_cam1.config(image=tkimg1) self.label_filename1.config(text=person_id + "_00.jpg") self.label_person_image_cam1.image = tkimg1 # keep a reference
def next2(self): # 确认键的操作 person_id1 = tools.format_id(self.current_person_id1) # 把2变成0002这样 person_id2 = tools.format_id(self.current_person_id2) self.current_img_id_cam2 += 1 if (self.current_img_id_cam2 == 10): self.current_img_id_cam2 = 0 bm2 = Image.open(dataset_dir + person_id2 + "_0" + str(self.current_img_id_cam2) + ".jpg") tkimg2 = ImageTk.PhotoImage(bm2) self.label_person_image_cam2.config(image=tkimg2) self.label_person_image_cam2.image = tkimg2 # keep a reference self.label_filename2.config(text=person_id2 + "_0" + str(self.current_img_id_cam2) + ".jpg") self.test_pair( dataset_dir + person_id1 + "_0" + str(self.current_img_id_cam1) + ".jpg", dataset_dir + person_id2 + "_0" + str(self.current_img_id_cam2) + ".jpg")
def next1(self): # 确认键的操作 person_id1 = tools.format_id(self.current_person_id1) person_id2 = tools.format_id(self.current_person_id2) self.current_img_id_cam1 += 1 if (self.current_img_id_cam1 == 10): self.current_img_id_cam1 = 0 bm1 = Image.open(dataset_dir + person_id1 + "_0" + str(self.current_img_id_cam1) + ".jpg") tkimg1 = ImageTk.PhotoImage(bm1) self.label_person_image_cam1.config(image=tkimg1) self.label_person_image_cam1.image = tkimg1 # keep a reference self.label_filename1.config(text=person_id1 + "_0" + str(self.current_img_id_cam1) + ".jpg") self.test_pair( dataset_dir + person_id1 + "_0" + str(self.current_img_id_cam1) + ".jpg", dataset_dir + person_id2 + "_0" + str(self.current_img_id_cam2) + ".jpg")
def confirm2(self): # 确认键的操作 self.current_person_id2 = int(self.entry_id2.get()) self.current_img_id_cam2 = 0 person_id = tools.format_id(self.current_person_id2) bm2 = Image.open(dataset_dir + person_id + "_05.jpg") tkimg2 = ImageTk.PhotoImage(bm2) self.label_person_image_cam2.config(image=tkimg2) self.label_filename2.config(text=person_id + "_00.jpg") self.label_person_image_cam2.image = tkimg2 # keep a reference
def confirm1(self): # 确认键的操作 person_id = tools.format_id(self.current_person_id) self.current_img_id_cam1 += 1 if (self.current_img_id_cam1 == 5): self.current_img_id_cam1 = 0 bm1 = Image.open(dataset_dir + person_id + "_0" + str(self.current_img_id_cam1) + ".jpg") tkimg1 = ImageTk.PhotoImage(bm1) self.label_person_image_cam1.config(image=tkimg1) self.label_person_image_cam1.image = tkim1 # keep a reference self.label_filename1.config(text=person_id + "_0" + str(self.current_img_id_cam1) + ".jpg")
def confirm2(self): # 确认键的操作 person_id = tools.format_id(self.current_person_id) self.current_img_id_cam2 += 1 if (self.current_img_id_cam2 == 10): self.current_img_id_cam2 = 5 bm2 = Image.open(dataset_dir + person_id + "_0" + str(self.current_img_id_cam2) + ".jpg") tkimg2 = ImageTk.PhotoImage(bm2) self.label_person_image_cam2.config(image=tkimg2) self.label_person_image_cam2.image = tkimg2 # keep a reference self.label_filename2.config(text=person_id + "_0" + str(self.current_img_id_cam2) + ".jpg")
def confirm(self): # 确认键的操作 self.current_person_id = int(self.e.get()) person_id = tools.format_id(self.current_person_id) bm1 = Image.open(dataset_dir + person_id + "_00.jpg") tkimg1 = ImageTk.PhotoImage(bm1) bm2 = Image.open(dataset_dir + person_id + "_05.jpg") tkimg2 = ImageTk.PhotoImage(bm2) self.label_person_image_cam1.config(image=tkimg1) self.label_filename1.config(text=person_id + "_00.jpg") self.label_person_image_cam1.image = tkimg1 # keep a reference self.label_person_image_cam2.config(image=tkimg2) self.label_filename2.config(text=person_id + "_05.jpg") self.label_person_image_cam2.image = tkimg2 # keep a reference
def next2(self): # 确认键的操作 person_id1 = tools.format_id(self.current_person_id_cam1) # 把2变成0002这样
def confirm_reid(self): # 确认键的操作 self.text_console.delete(1.0, END) self.text_console.insert( 1.0, "行人ID:" + str(self.current_person_id_cam1) + ",开始重识别......\n") query_img, test_img, query_label, test_label = cuhk03_api.get_img( self.current_person_id_cam1) test_img = preprocess_input(test_img) query_img = preprocess_input(query_img) start = time.time() _, test_feature = self.class_triplet_model.predict( test_img) # [_,2048] test_feature = normalize(test_feature) end = time.time() # output feature f = codecs.open("testfeature.txt", 'w', 'utf-8') for feature in test_feature: for dim in feature: f.write(str(dim)) f.write(" ") f.write('\n') # output feature t1 = start - end self.text_console.insert(3.0, "提取gallery特征所需时间:" + str(end - start) + "s\n") print(len(test_feature[0])) start = time.time() _, query_feature = self.class_triplet_model.predict(query_img) # output feature f = codecs.open( "features/" + str(self.current_person_id_cam1) + ".txt", 'w', 'utf-8') for feature in query_feature: for dim in feature: f.write(str(dim)) f.write(" ") f.write('\n') # output feature query_feature = normalize(query_feature) end = time.time() # output feature f = codecs.open("queryfeature.txt", 'w', 'utf-8') for feature in query_feature: for dim in feature: f.write(str(dim)) f.write(" ") f.write('\n') # output feature self.text_console.insert(3.0, "提取query特征所需时间:" + str(end - start) + "s\n") start = time.time() top1, top1id = self.single_query(query_feature, test_feature, query_label, test_label, test_num=1) end = time.time() self.text_console.insert(3.0, "计算欧几里得距离所需时间:" + str(end - start) + "s\n") person_id = tools.format_id(top1id) self.current_person_id_cam2 = top1id self.current_img_id_cam2 = 5 bm2 = Image.open(dataset_dir + person_id + "_0" + str(self.current_img_id_cam2) + ".jpg") tkimg2 = ImageTk.PhotoImage(bm2) # 补一下左图,不知道为什么显示不出来 self.current_person_id_cam1 = int(self.entry_id1.get()) self.current_img_id_cam1 = 0 person_id = tools.format_id(self.current_person_id_cam1) bm1 = Image.open(dataset_dir + person_id + "_00.jpg") tkimg1 = ImageTk.PhotoImage(bm1) self.label_person_image_cam2.config(image=tkimg2) self.label_filename2.config(text=person_id + "_05.jpg") self.label_person_image_cam1.image = tkimg2 # keep a reference self.label_person_image_cam1.config(image=tkimg1) self.label_filename1.config(text=person_id + "_00.jpg") self.label_person_image_cam1.image = tkimg1 # keep a reference