Add optical flow Auto Segment button

Annotators can now press Auto Segment to replace the current mask with
an automatic river segmentation based on dense optical flow magnitude
and frame brightness. The result is pushed onto the undo stack, so it
can be refined or reverted like any other mask operation.

Parameters (norm_squared_threshold, gaussian_kernel, brightness_range)
live in a separate config/optical_flow_config.yaml; the button is only
enabled when optical_flow_config_file is set in config.yaml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 15:13:10 +02:00
parent 47432cec4f
commit 67c9a1152c
6 changed files with 130 additions and 13 deletions

View File

@@ -28,6 +28,7 @@ class AppConfig:
data_dir: str = "data/clips"
out_dir: str = "data/annotation_results"
clips_file: str = "config/clips.txt"
optical_flow_config_file: str = ""
questions: list = field(default_factory=list)
filenames: FilenameConfig = field(default_factory=FilenameConfig)
@@ -51,6 +52,22 @@ class AppConfig:
]
@dataclass
class OpticalFlowConfig:
enabled: bool = False
norm_squared_threshold: float = 0.3
gaussian_kernel: tuple[int, int] = (5, 5)
brightness_range: tuple[int, int] = (20, 235)
def load_optical_flow_config(path: Path) -> OpticalFlowConfig:
with open(path) as f:
data = yaml.safe_load(f)
data["gaussian_kernel"] = tuple(data["gaussian_kernel"])
data["brightness_range"] = tuple(data["brightness_range"])
return OpticalFlowConfig(**data)
def load_config(path: Path) -> AppConfig:
with open(path) as f:
data = yaml.safe_load(f)