You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
2.4 KiB
Python
107 lines
2.4 KiB
Python
import cv2
|
|
import os
|
|
|
|
from yolov8_det import analysis_yolov8
|
|
|
|
|
|
class atm_det:
|
|
|
|
# 根据bbox截取小图
|
|
def cut_img_bbox(img,bbox):
|
|
|
|
# blist = bbox.tolist()
|
|
|
|
x_min = bbox[0]
|
|
y_min = bbox[1]
|
|
x_max = bbox[2]
|
|
y_max = bbox[3]
|
|
|
|
obj_img = img[int(y_min):int(y_max), int(x_min):int(x_max)] #cv2裁剪出目标框中的图片
|
|
#保存图片
|
|
# cut_images = obj_img_path + '\\' + '%s_%s'%(img_name, count) + '.jpg'
|
|
|
|
return obj_img
|
|
|
|
|
|
# 获得atm检测中工作人员数据、并截取小图
|
|
def get_person_result(imgpath,model_person):
|
|
|
|
|
|
imgname = os.path.basename(imgpath)
|
|
|
|
images = cv2.imread(imgpath)
|
|
|
|
per_result = analysis_yolov8(images=images,
|
|
model_coco=model_person,
|
|
confidence=0.5
|
|
)
|
|
|
|
|
|
return per_result
|
|
|
|
|
|
# 检测手部动作是否有握笔签字、输入密码等动作
|
|
def get_pph_result(imgpath,model_pp_hand):
|
|
|
|
images = cv2.imread(imgpath)
|
|
|
|
pph_result = analysis_yolov8(images=images,
|
|
model_coco=model_pp_hand,
|
|
confidence=0.5
|
|
)
|
|
|
|
return pph_result
|
|
|
|
|
|
# 获得当前屏幕上按钮信息
|
|
def get_blue_result(images,model_blue):
|
|
|
|
|
|
blue_result = analysis_yolov8(images=images,
|
|
model_coco=model_blue,
|
|
confidence=0.5
|
|
)
|
|
|
|
|
|
blues_list = []
|
|
for blues in blue_result:
|
|
|
|
blue = list(blues.values())[0]
|
|
blues_list.append(blue)
|
|
|
|
|
|
|
|
return blues_list
|
|
|
|
# 获得当前屏幕信息
|
|
def get_screen_result(imgpath,model_screen):
|
|
|
|
|
|
imgname = os.path.basename(imgpath)
|
|
|
|
images = cv2.imread(imgpath)
|
|
|
|
screen_result = analysis_yolov8(images=images,
|
|
model_coco=model_screen,
|
|
confidence=0.5
|
|
)
|
|
|
|
return screen_result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|