def api_ctl2(self, pic_path66): if self.thread_run: return self.thread_run = False self.thread_run2 = False colorstr, textstr = api_pic(pic_path66) self.apistr = colorstr + textstr self.show_roi1(textstr, None, colorstr) self.show_roi2(textstr, None, colorstr) localtime = time.asctime(time.localtime(time.time())) value = [localtime, None, None, None, None, self.apistr, self.pic_source] print(localtime, "|", "|", "| ", self.apistr, "|", self.pic_source) img_excel.excel_add(value) img_sql.sql(value[0], value[1], value[2], value[3], value[4], value[5], value[6])
def pic(self, pic_path): self.apistr = None img_bgr = img_math.img_read(pic_path) first_img, oldimg = self.predictor.img_first_pre(img_bgr) if not self.cameraflag: self.imgtk = self.get_imgtk(img_bgr) self.image_ctl.configure(image=self.imgtk) th1 = ThreadWithReturnValue(target=self.predictor.img_color_contours, args=(first_img, oldimg)) th2 = ThreadWithReturnValue(target=self.predictor.img_only_color, args=(oldimg, oldimg, first_img)) th1.start() th2.start() r_c, roi_c, color_c = th1.join() r_color, roi_color, color_color = th2.join() try: Plate = HyperLPR_PlateRecogntion(img_bgr) # print(Plate[0][0]) r_c = Plate[0][0] r_color = Plate[0][0] except: pass if not color_color: color_color = color_c if not color_c: color_c = color_color self.show_roi2(r_color, roi_color, color_color) self.show_roi1(r_c, roi_c, color_c) # self.center_window() localtime = time.asctime(time.localtime(time.time())) if not self.cameraflag: if not (r_color or color_color or r_c or color_c): self.api_ctl2(pic_path) return value = [ localtime, color_c, r_c, color_color, r_color, self.apistr, self.pic_source ] img_excel.excel_add(value) img_sql.sql(value[0], value[1], value[2], value[3], value[4], value[5], value[6]) print(localtime, "|", color_c, r_c, "|", color_color, r_color, "| ", self.apistr, "|", self.pic_source)