diff --git a/config/config_models.py b/config/config_models.py index 90b7f3f..1579098 100644 --- a/config/config_models.py +++ b/config/config_models.py @@ -13,6 +13,7 @@ class ROIType(str, Enum): """ROI类型枚举""" POLYGON = "polygon" RECTANGLE = "rectangle" + FULLSCREEN = "fullscreen" class AlgorithmType(str, Enum): diff --git a/core/preprocessor.py b/core/preprocessor.py index 5571b70..6343aac 100644 --- a/core/preprocessor.py +++ b/core/preprocessor.py @@ -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])