示例#1
0
    def scan_and_save_drives(self):
        models_usbs = GetModelUSB().init()
        serial_usbs = GetSerialUSB().init()

        for index_drive in range(0, len(models_usbs)):
            print(
                f"Inserting usb model {models_usbs[index_drive]}, serial {serial_usbs[index_drive]} in DB"
            )
            sql().insert(index_drive, models_usbs[index_drive],
                         serial_usbs[index_drive])
示例#2
0
 def api_ctl2(self, pic_path66):
     """自己定义的算法完全没识别出车牌信息,则调用api_ctl2进行车牌识别"""
     if self.thread_run:
         return
     self.thread_run = False
     self.thread_run2 = False
     colorstr, textstr = api_pic(
         pic_path66)  # 调用api进行车牌识别,返回颜色字段和车牌号字段,分别赋值给colorstr, textstr
     self.apistr = colorstr + textstr  # self.apistr字段的值包括车牌颜色和车牌号信息,即完整的车牌信息
     self.show_roi2(textstr, None, colorstr)
     localtime = time.asctime(time.localtime(time.time()))
     value = [localtime, textstr, colorstr, self.pic_source]
     print(localtime, textstr, colorstr, self.pic_source)
     img_sql.sql(value[0], value[1], value[2], value[3])
示例#3
0
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()

        usb_list = sql().get_table()
        usb_list.pop()

        for usbs in usb_list:
            usbs = list(usbs)
            self.create_widgets(usbs)

        self.label = tk.Label(self,
                              text="GREEN is activated and RED is deactivated",
                              font=("Calibri", "9"),
                              bg=background,
                              fg="#CB5BFF")
        self.label.pack(side="bottom")

        self.quit = tk.Button(self,
                              text="SAIR",
                              fg="#49B3D1",
                              font=("Calibri", "11", "bold"),
                              bg="#D2D2D2",
                              command=self.master.quit)
        self.quit.pack(side="bottom", pady=50)
示例#4
0
    def pic(self, pic_path):
        """对图像进行处理,处理完成后在主窗口左边显示要识别的图像,
        在右边展示--形状定位车牌位置--形状定位识别结果--颜色定位车牌位置--颜色定位识别结果--的信息"""
        self.apistr = None  # self.apistr字段表示的是,调用api进行车牌识别返回的车牌完整信息的字符串
        img_bgr = img_math.img_read(
            pic_path)  # 以uint8方式读取pic_path返回给img_bgr,即返回以uint8方式读取的彩色照片
        first_img, oldimg = self.predictor.img_first_pre(img_bgr)
        # 返回Otsu’s二值化边缘化的新图像和原图,需要两个变量接收
        # 其中first_img接收Otsu’s二值化边缘化的新图像
        if not self.cameraflag:
            # 这个if的作用相当于vedio_thread(),即传入的图像不是由相机拍摄的图像,将图像显示在主窗口左边
            # self.cameraflag置为0时,即传入的图像不是由相机拍摄的图像,将图像显示在主窗口左边
            self.imgtk = self.get_imgtk(img_bgr)
            self.image_ctl.configure(image=self.imgtk)  # 将图像显示在主窗口左边
        th2 = ThreadWithReturnValue(target=self.predictor.color_and_contour,
                                    args=(oldimg, oldimg, first_img))
        # 创建线程th2,通过run()方法回调color_and_contour()方法,并将args作为参数传入color_and_contour()方法中
        th2.start()
        # 开启线程th2,将color_and_contour()方法返回的结果存储到变量r_color, roi_color, color_color中
        r_color, roi_color, color_color = th2.join()

        try:
            Plate = HyperLPR_PlateRecogntion(img_bgr)
            # HyperLPR_PlateRecogntion是未完成的通过HyperLPR库进行车牌识别的更高版本
            # print(Plate[0][0])
            r_c = Plate[0][0]
            r_color = Plate[0][0]
        except:
            pass
        self.show_roi2(r_color, roi_color, color_color)
        localtime = time.asctime(time.localtime(time.time()))
        if not self.cameraflag:
            if not (r_color or color_color):
                self.api_ctl2(pic_path)
                return
            value = [localtime, color_color, r_color, self.pic_source]
            # img_excel.excel_add(value)
            img_sql.sql(value[0], value[1], value[2], value[3])
        print(localtime, "|", color_color, r_color, "| ", self.pic_source)
示例#5
0
def scan_to_lock():
    serial_list = GetSerialUSB().init()
    all_table = sql().get_table()
    all_table.pop()

    for usb in all_table:
        if usb[3] == 1:
            if usb[2] not in serial_list:
                ctypes.windll.user32.LockWorkStation()
            elif usb[2] in serial_list:
                print(f"Usb key connected | Key used => {usb[2]}")
                pass
            else:
                print("Something wrong happened")
        else:
            print(f"Serial {usb[2]} has found but is not activated")

    sleep(1)
    scan_to_lock()
示例#6
0
    def button_action(self, usb):
        print(f"Updating status of model => {usb[1]} with serial {usb[2]}")
        usb[3] = sql().update_status_usb(usb)

        return usb