From 8f5d31725eac5c77b887cdbd18b36e08f8591697 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sun, 13 Aug 2023 19:42:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=94=A8PaddleOCR=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/riic_report_analysis.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/riic_report_analysis.py b/apps/riic_report_analysis.py index f99ebfb..f55fdb9 100644 --- a/apps/riic_report_analysis.py +++ b/apps/riic_report_analysis.py @@ -1,7 +1,19 @@ -from pepperbot.core.message.chain import MessageChain, Text +from pepperbot.core.message.chain import MessageChain, Image, Text +from paddleocr import PaddleOCR +import os class RIICReportAnalysis: async def group_message(self, chain: MessageChain): - if chain.pure_text == "芜湖": - await chain.onebot_reply(Text("起飞")) + if len(chain) != 1: + return + img_seg: Image = chain[0] + img_path = await img_seg.download() + print(f"Image saved to {img_path}") + + ocr = PaddleOCR(use_angle_cls=False, lang="ch", use_gpu=False) + ocr_text = ocr.ocr(img_path, det=False) + print(ocr_text) + + os.remove(img_path) + print(f"file removed.")