New pipeline widget framework

This commit is contained in:
2025-08-01 18:49:27 +02:00
parent af4371ebe4
commit 8b4105a261
9 changed files with 304 additions and 191 deletions

View File

@ -6,13 +6,35 @@ from .event_bus import EventBus
class ImagePipeline:
def __init__(self, bus: EventBus):
self.bus = bus
self.stages = {}
self.stages = []
self.stagedata = {}
def add_stage(self, name: str, img: np.ndarray):
self.stages[name] = img.astype(np.float32)
# notify widgets of updated stage list and data
self.bus.publish_deferred("pipeline_stages", list(self.stages.keys()))
self.bus.publish_deferred("pipeline_stage", (name, self.stages[name]))
def register_stage(self, name: str):
self.stages.append(name)
self.stagedata[name] = None
self.bus.publish_deferred("pipeline_stages", self.stages)
return len(self.stages) - 1
def get_stage(self, name: str):
return self.stages.get(name)
def rename_stage(self, id: int, name: str):
if id >= 0 and id < len(self.stages):
self.stages[id] = name
self.bus.publish_deferred("pipeline_stages", self.stages)
def publish(self, id: int, img: np.ndarray):
self.stagedata[id] = img.astype(np.float32)
self.bus.publish_deferred("pipeline_stage", (id, self.stagedata[id]))
def get_stage_data(self, id: int):
if id >= 0 and id < len(self.stages):
return self.stagedata[id]
else:
return None
def get_stage_name(self, id:int):
if id >= 0 and id < len(self.stages):
return self.stages[id]
else:
return None
def republish_stages(self):
self.bus.publish_deferred("pipeline_stages", self.stages)