功能:支持 fullscreen ROI 类型 — 全图不裁剪直接推理

This commit is contained in:
2026-03-30 11:07:44 +08:00
parent 42a8cf3ce3
commit f0d01d9a0d
2 changed files with 8 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ class ROIType(str, Enum):
"""ROI类型枚举"""
POLYGON = "polygon"
RECTANGLE = "rectangle"
FULLSCREEN = "fullscreen"
class AlgorithmType(str, Enum):

View File

@@ -43,7 +43,9 @@ class ROICropper:
裁剪后的图像失败返回None
"""
try:
if roi.roi_type == ROIType.RECTANGLE:
if roi.roi_type == ROIType.FULLSCREEN:
return image.copy()
elif roi.roi_type == ROIType.RECTANGLE:
return self._crop_rectangle(image, roi.coordinates)
elif roi.roi_type == ROIType.POLYGON:
return self._crop_polygon(image, roi.coordinates)
@@ -137,7 +139,10 @@ class ROICropper:
height, width = image_shape
mask = np.zeros((height, width), dtype=np.uint8)
if roi.roi_type == ROIType.RECTANGLE:
if roi.roi_type == ROIType.FULLSCREEN:
mask[:] = 255
elif roi.roi_type == ROIType.RECTANGLE:
if len(roi.coordinates) >= 2:
x1, y1 = int(roi.coordinates[0][0]), int(roi.coordinates[0][1])
x2, y2 = int(roi.coordinates[1][0]), int(roi.coordinates[1][1])