1.kangda类添加图像裁剪\n2.ocr图像前添加图像裁剪处理
This commit is contained in:
parent
035498c19b
commit
0c8b6add64
@ -281,6 +281,10 @@ class EventSyncService:
|
||||
return
|
||||
|
||||
for image in image_list:
|
||||
|
||||
# 裁剪图片, 去掉时间日期信息
|
||||
self.kangda.crop_timestamp_with_cv2(image.localPath, image.localPath, 0, 0, 106, 115)
|
||||
|
||||
result = self.ocr.image_inference(image.localPath)
|
||||
values, conf = self.ocr.parse_result(result)
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import re
|
||||
import os
|
||||
from urllib import response
|
||||
import cv2
|
||||
# from urllib import response
|
||||
import yaml
|
||||
import requests
|
||||
from app.util.status import TemperatureStatus
|
||||
@ -438,6 +439,24 @@ class Kangda:
|
||||
return TemperatureStatus.ALDATE
|
||||
|
||||
return TemperatureStatus.NORMAL
|
||||
|
||||
|
||||
# 裁剪图片
|
||||
def crop_timestamp_with_cv2(self, input_path, output_path, x, y, w, h):
|
||||
"""
|
||||
裁剪输入图片中从 (x, y) 开始,宽度为 w、高度为 h 之外的区域。
|
||||
也就是保留从 (x+w, y+h) 到右下角的部分。
|
||||
"""
|
||||
img = cv2.imread(input_path)
|
||||
if img is None:
|
||||
raise FileNotFoundError(f"无法打开 {input_path}")
|
||||
height, width = img.shape[:2]
|
||||
|
||||
# 定义裁剪 ROI 区域
|
||||
cropped = img[y+h:height, x+w:width]
|
||||
|
||||
# 保存结果
|
||||
cv2.imwrite(output_path, cropped)
|
||||
|
||||
|
||||
|
||||
|
||||
12
test_t.py
12
test_t.py
@ -32,11 +32,17 @@ kangda = Kangda()
|
||||
#---------------------------测试康达前端登录end--------------------------------------
|
||||
|
||||
#--------------------------测试康达后台获取机器人任务-----------------------------------
|
||||
token = kangda._login_gettoken()
|
||||
task_list = kangda._get_task(token, ["6865c4ce61ee45a69e79f62eee55b83c"])
|
||||
print(task_list)
|
||||
# token = kangda._login_gettoken()
|
||||
# task_list = kangda._get_task(token, ["6865c4ce61ee45a69e79f62eee55b83c"])
|
||||
# print(task_list)
|
||||
#--------------------------测试康达后台获取机器人任务end-------------------------------------
|
||||
|
||||
#------------------------测试图片裁剪--------------------------------------------------
|
||||
image_path = "/home/admin-root/haotian/康达瑞贝斯/康达后台项目/imagesDownload/ffb447d5f89ea303cfeb25370495ad26.jpeg"
|
||||
ouput_path = "/home/admin-root/haotian/康达瑞贝斯/康达后台项目/imagesDownload/ffb447d5f89ea303cfeb25370495ad26.jpeg"
|
||||
kangda.crop_timestamp_with_cv2(image_path, ouput_path, 0, 0, 106, 115)
|
||||
#------------------------测试图片裁剪end----------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user