功能:支持 fullscreen ROI 类型 — 全图不裁剪直接推理
This commit is contained in:
@@ -13,6 +13,7 @@ class ROIType(str, Enum):
|
|||||||
"""ROI类型枚举"""
|
"""ROI类型枚举"""
|
||||||
POLYGON = "polygon"
|
POLYGON = "polygon"
|
||||||
RECTANGLE = "rectangle"
|
RECTANGLE = "rectangle"
|
||||||
|
FULLSCREEN = "fullscreen"
|
||||||
|
|
||||||
|
|
||||||
class AlgorithmType(str, Enum):
|
class AlgorithmType(str, Enum):
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ class ROICropper:
|
|||||||
裁剪后的图像,失败返回None
|
裁剪后的图像,失败返回None
|
||||||
"""
|
"""
|
||||||
try:
|
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)
|
return self._crop_rectangle(image, roi.coordinates)
|
||||||
elif roi.roi_type == ROIType.POLYGON:
|
elif roi.roi_type == ROIType.POLYGON:
|
||||||
return self._crop_polygon(image, roi.coordinates)
|
return self._crop_polygon(image, roi.coordinates)
|
||||||
@@ -137,7 +139,10 @@ class ROICropper:
|
|||||||
height, width = image_shape
|
height, width = image_shape
|
||||||
mask = np.zeros((height, width), dtype=np.uint8)
|
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:
|
if len(roi.coordinates) >= 2:
|
||||||
x1, y1 = int(roi.coordinates[0][0]), int(roi.coordinates[0][1])
|
x1, y1 = int(roi.coordinates[0][0]), int(roi.coordinates[0][1])
|
||||||
x2, y2 = int(roi.coordinates[1][0]), int(roi.coordinates[1][1])
|
x2, y2 = int(roi.coordinates[1][0]), int(roi.coordinates[1][1])
|
||||||
|
|||||||
Reference in New Issue
Block a user