fix multi apps

This commit is contained in:
tsuky_chen
2024-03-09 18:50:16 +08:00
parent f4ec36bdfb
commit 5b07ec17bf

View File

@@ -200,14 +200,13 @@ def compare_docx_images(docx_file1, docx_file2):
return 1
import pytesseract
import easyocr
def compare_image_text(image_path, rule):
img = Image.open(image_path)
img_text = pytesseract.image_to_string(img)
reader = easyocr.Reader(['en'])
result = reader.readtext(image_path)
extracted_text = ' '.join([entry[1] for entry in result])
if rule['type'] == 'text':
return 1 if rule['text'] in img_text else 0
return 1 if rule['text'] in extracted_text else 0
else:
raise ValueError("Unsupported rule type")