def query_ocr(self, directory, result_photo): keyword_result = {} for k_p in result_photo: save_text_area = os.path.join(directory, k_p) text_binary = get_area_data(save_text_area) #测试指定图片 # testfile = 'testjpg.png' # testfile = 'test14.png' # text_binary = get_area_data(os.path.join(data_directory,testfile)) if self.ocr_engine == 'baidu': print("用百度去OCR识别--" + k_p + "--了!!!\n") keyword_q = get_text_from_image_baidu( image_data=text_binary, app_id=self.app_id, app_key=self.app_key, app_secret=self.app_secret, api_version=self.api_version, timeout=5) if not keyword_q: print("没识别出来,随机选吧!!!\n") print("题目出现的时候按F,我就自动帮你去搜啦~\n") return key_tmp = "" for k in keyword_q: key_tmp = key_tmp + k self.keyword[k_p] = key_tmp
def testocr(self): testfile = 'test14.png' text_binary = get_area_data(os.path.join(self.data_directory,testfile)) if self.ocr_engine == 'baidu': print("用百度去OCR识别了!!!\n") keyword_to = get_text_from_image_baidu(image_data=text_binary, app_id=self.app_id, app_key=self.app_key, app_secret=self.app_secret, api_version=self.api_version, timeout=5) print(keyword)