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:
@@ -1,3 +1,5 @@
|
||||
import ast
|
||||
import importlib
|
||||
import importlib.util
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -7,6 +9,47 @@ from types import ModuleType, SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
SOURCE_ROOT = PROJECT_ROOT / "src"
|
||||
sys.path.insert(0, str(SOURCE_ROOT))
|
||||
COMMON_ROOT = SOURCE_ROOT / "anyimage" / "common"
|
||||
COMMON_MODULES = {
|
||||
"ai",
|
||||
"depth",
|
||||
"image",
|
||||
"material",
|
||||
"node",
|
||||
"object",
|
||||
"selection",
|
||||
"viewport",
|
||||
}
|
||||
|
||||
|
||||
def test_common_modules_follow_business_boundaries():
|
||||
module_names = {
|
||||
path.stem
|
||||
for path in COMMON_ROOT.glob("*.py")
|
||||
if path.name != "__init__.py"
|
||||
}
|
||||
assert module_names == COMMON_MODULES
|
||||
|
||||
for module_name in COMMON_MODULES:
|
||||
importlib.import_module(f"anyimage.common.{module_name}")
|
||||
|
||||
ai_ui_definitions = {
|
||||
path.name
|
||||
for path in COMMON_ROOT.glob("*.py")
|
||||
if "def draw_ai_setup(" in path.read_text(encoding="utf-8")
|
||||
or "def draw_ai_property(" in path.read_text(encoding="utf-8")
|
||||
}
|
||||
assert ai_ui_definitions == {"ai.py"}
|
||||
|
||||
init_tree = ast.parse(
|
||||
(COMMON_ROOT / "__init__.py").read_text(encoding="utf-8")
|
||||
)
|
||||
assert not any(
|
||||
isinstance(node, (ast.Import, ast.ImportFrom))
|
||||
for node in init_tree.body
|
||||
)
|
||||
|
||||
|
||||
def load_image_modules():
|
||||
@@ -24,12 +67,12 @@ def load_image_modules():
|
||||
|
||||
module_paths = (
|
||||
(
|
||||
"anyimage.common.image_data",
|
||||
"anyimage.common.image",
|
||||
PROJECT_ROOT
|
||||
/ "src"
|
||||
/ "anyimage"
|
||||
/ "common"
|
||||
/ "image_data.py",
|
||||
/ "image.py",
|
||||
),
|
||||
(
|
||||
"anyimage.common.node",
|
||||
@@ -39,6 +82,14 @@ def load_image_modules():
|
||||
/ "common"
|
||||
/ "node.py",
|
||||
),
|
||||
(
|
||||
"anyimage.common.material",
|
||||
PROJECT_ROOT
|
||||
/ "src"
|
||||
/ "anyimage"
|
||||
/ "common"
|
||||
/ "material.py",
|
||||
),
|
||||
(
|
||||
"anyimage.common.object",
|
||||
PROJECT_ROOT
|
||||
|
||||
Reference in New Issue
Block a user