新增支持逻辑分辨率为2.0的机型
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
from typing import List, Tuple, Union, Optional
|
||||
@@ -162,6 +164,15 @@ class OCRUtils:
|
||||
centers: [(cx, cy), ...]
|
||||
boxes: [[x1,y1,x2,y2], ...] (np.ndarray, int)
|
||||
"""
|
||||
|
||||
if not os.path.isfile(template_path):
|
||||
print(f"模板文件不存在 → {template_path}")
|
||||
raise FileNotFoundError(f"模板文件不存在 → {template_path}")
|
||||
|
||||
size = os.path.getsize(template_path)
|
||||
if size == 0:
|
||||
print(f"模板文件大小为 0 → {template_path} ")
|
||||
raise ValueError(f"模板文件大小为 0 → {template_path}")
|
||||
# 模板(灰度)
|
||||
template = cv2.imread(template_path, cv2.IMREAD_GRAYSCALE)
|
||||
if template is None:
|
||||
@@ -230,4 +241,4 @@ class OCRUtils:
|
||||
# 全部尝试失败
|
||||
if return_boxes:
|
||||
return last_centers, last_boxes
|
||||
return last_centers
|
||||
return last_centers
|
||||
Reference in New Issue
Block a user