Add image selection refinement functionality with BEN2 integration

- Implemented viewport.py for handling 3D view projections, gestures, and overlay drawing.
- Created refine_image_selection.py to manage the refinement of gesture masks and output image bounds.
- Added selection module with refine_selection.py to process and crop images based on alpha channel visibility.
- Introduced __init__.py for selection module to expose refine_selection function.
This commit is contained in:
2026-08-31 22:10:05 +08:00
parent 14d63001d2
commit c97b4a3e41
76 changed files with 2127 additions and 1137 deletions

View File

@@ -216,17 +216,17 @@ def upscale_model_label(model_key):
return model.label if model is not None else model_key
def refine_region_property():
def refine_selection_property():
return bpy.props.BoolProperty(
name="Fit to Foreground",
description="Use BEN2 to fit the gesture mask to foreground content",
name="Refine Selection",
description="Use BEN2 to refine the selection to foreground content",
default=False,
)
def cutout_generate_normal_property():
return bpy.props.BoolProperty(
name="Generate Normal Map",
name="Normal Map",
description=(
"Generate a MoGe-2 normal texture; Depth Surface uses Object Space "
"and other shapes use Tangent Space"
@@ -235,25 +235,26 @@ def cutout_generate_normal_property():
)
def cutout_point_spacing_property():
return bpy.props.IntProperty(
name="Mesh Sampling Spacing",
description=(
"Source image pixels between neighboring mesh points; smaller values "
"create denser geometry"
def cutout_mesh_detail_property():
return bpy.props.EnumProperty(
name="Mesh Detail",
description="Mesh sampling density",
items=(
("LOW", "Low", "32 source image pixels between neighboring mesh points"),
("MEDIUM", "Medium", "16 source image pixels between neighboring mesh points"),
("HIGH", "High", "8 source image pixels between neighboring mesh points"),
("ULTRA", "Ultra", "4 source image pixels between neighboring mesh points"),
),
default=32,
min=4,
max=32,
default="LOW",
)
class AnyImageSettings(bpy.types.PropertyGroup):
cutout_point_spacing: cutout_point_spacing_property()
cutout_mesh_detail: cutout_mesh_detail_property()
cutout_generate_normal: cutout_generate_normal_property()
cutout_refine_region: refine_region_property()
image_box_refine_region: refine_region_property()
image_lasso_refine_region: refine_region_property()
cutout_refine_selection: refine_selection_property()
image_box_refine_selection: refine_selection_property()
image_lasso_refine_selection: refine_selection_property()
input_path: bpy.props.StringProperty(
name="Image or Video",
description="A single image or video file used for reconstruction",