def send_char_to_l2_not_img(self):
     self.counter = self.counter + 1
     if self.counter > 30000:
         self.counter = 1
     send_to_l2(self.sock, self.log_oper, "Error", "", "", "", self.counter,
                self.mark)
     self.log_oper.add_log("Normal>>无识别字符发送到二级")
Пример #2
0
    def send_char_to_l2_not_img(self):
        self.counter = self.counter + 1
        if self.counter > 30000:
            self.counter = 1

        if self.curr_steel_img_info is not None:
            #保存字符图片到二级发送文件夹
            img_name, steel_img = self.curr_steel_img_info[
                0], self.curr_steel_img_info[1]
            steel_img_resize = cv2.resize(
                steel_img,
                (steel_img.shape[1], int(steel_img.shape[1] * 0.75)))
            datetime = time.strftime("%Y%m%d")
            path_steel_l2_curr = ((self.path_char_l2 + "\%s") % datetime)
            if not os.path.exists(path_steel_l2_curr):
                os.mkdir(path_steel_l2_curr)
            save_l2_steel_img_path = os.path.join(path_steel_l2_curr, img_name)
            cv2.imwrite(save_l2_steel_img_path, steel_img_resize)
            img_path = os.path.join(datetime, img_name)
            self.log_oper.add_log("Normal>>成功保存无字符图像到二级文件夹")

            send_to_l2(self.sock, self.log_oper, "Error", "", "", img_path,
                       self.counter, self.mark)
        else:
            send_to_l2(self.sock, self.log_oper, "Error", "", "", "",
                       self.counter, self.mark)

        self.log_oper.add_log("Normal>>无识别字符发送到二级")
        self.curr_steel_img_info = [None, None]
 def send_char_to_l2_not_steel_no(self):
     self.counter=self.counter+1
     if self.counter>30000:
         self.counter=1
     
     img_name,char_roi,src_img=self.curr_char_img_info["img_name"],self.curr_char_img_info["char_roi"],self.curr_char_img_info["src_img"]
     #保存字符图片到二级发送文件夹
     char_roi_resize=cv2.resize(char_roi,(char_roi.shape[1],int(char_roi.shape[1]*0.75)))
     datetime=time.strftime("%Y%m%d")
     path_char_l2_curr = ((self.path_char_l2 + "\%s") % datetime)
     if not os.path.exists(path_char_l2_curr):
         os.mkdir(path_char_l2_curr)
     save_l2_char_img_path = os.path.join(path_char_l2_curr,img_name)
     cv2.imwrite(save_l2_char_img_path,char_roi_resize)
     img_path=os.path.join(datetime,img_name)
     self.log_oper.add_log("Normal>>成功保存未识别字符到二级文件夹")
     #保存样本到文件夹
     datetime=time.strftime("%Y%m%d")
     save_sample_path = ((self.path_camera + "\%s") % datetime)
     if not os.path.exists(save_sample_path):
         os.mkdir(save_sample_path)
     save_sample_path_name = os.path.join(save_sample_path,img_name)
     cv2.imwrite(save_sample_path_name,src_img)      
     #
     send_to_l2(self.sock,self.log_oper,"None","","",img_path,self.counter,self.mark)
     self.log_oper.add_log("Normal>>未识别字符发送到二级")
     self.curr_char_img_info={"img_name":None,"char_roi":None,"src_img":None}
 def send_char_to_l2(self, steel_no, steel_type, steel_size, img_path):
     self.counter = self.counter + 1
     if self.counter > 30000:
         self.counter = 1
     send_to_l2(self.sock, self.log_oper, steel_no, steel_type, steel_size,
                img_path, self.counter, self.mark)
     self.log_oper.add_log("Normal>>识别字符发送到二级")
     self.last_steel_no = steel_no
    def send_char_to_l2_not_steel_no(self):
        self.counter = self.counter + 1
        if self.counter > 30000:
            self.counter = 1
        #保存字符图片到二级发送文件夹
        img_name, char_roi_cut = self.curr_char_img_info[
            0], self.curr_char_img_info[1]
        char_roi_cut_resize = cv2.resize(
            char_roi_cut,
            (char_roi_cut.shape[1], int(char_roi_cut.shape[1] * 0.75)))
        datetime = time.strftime("%Y%m%d")
        path_char_l2_curr = ((self.path_char_l2 + "\%s") % datetime)
        if not os.path.exists(path_char_l2_curr):
            os.mkdir(path_char_l2_curr)
        save_l2_char_img_path = os.path.join(path_char_l2_curr, img_name)
        cv2.imwrite(save_l2_char_img_path, char_roi_cut_resize)
        img_path = os.path.join(datetime, img_name)
        self.log_oper.add_log("Normal>>成功保存未识别字符到二级文件夹")

        send_to_l2(self.sock, self.log_oper, "None", "", "", img_path,
                   self.counter, self.mark)
        self.log_oper.add_log("Normal>>未识别字符发送到二级")
        self.curr_char_img_info = [None, None]