processors#
Real-time, per-frame processors for camera DataProducers.
A FrameProcessor subscribes to a camera’s signals.frame,
runs compute(img, idx, ts) on a daemon worker thread, and emits the
result on both signals.data (for the DataQueue / CSV logger) and a
Qt-compatible valueUpdated(time, value) signal (for the existing
SerialWidget plotter).
- class mesofield.processors.FrameProcessor[source]#
Bases:
objectBase class for per-frame, real-time processors.
Acquisition stays on the camera thread;
computeruns on a daemon worker thread fed by a bounded queue (size 1, drop-oldest replace) so processing latency cannot stall the camera. Subclasses implement one method:def compute(self, img, idx, ts) -> float | None: ...
Returning
Noneskips emission for that frame. Otherwise the scalar is emitted on:self.signals.data(value, ts)– psygnal; pushed onto the DataQueue / CSV logger when the processor is registered withDataManager.register_hardware_device().self.valueUpdated(t, value)–pyqtSignal(float, float); Qt’s cross-thread queued connection makesSerialWidgetsafe to drive from the worker thread.
- compute(img, idx, ts)[source]#
Subclass hook: return one scalar (or
None) per frame.Called on every frame the attached camera emits. Implementations should be fast — anything heavy will starve the camera buffer. Return
Noneto skip emitting a sample for this frame.
- attach(camera=None)[source]#
Attach to a camera’s
signals.frameand start the worker.cameradefaults to whatever was passed at construction time (self.camera); callers building processors first and attaching later may pass it explicitly.- Parameters:
camera (Optional['DataProducer'])
- Return type:
None
- class mesofield.processors.FrameMean[source]#
Bases:
FrameProcessor
- mesofield.processors.register_processor(name)[source]#
Class decorator registering a
FrameProcessorundername.The name is what a config
processorsentry uses as itstype.- Parameters:
name (str)
- mesofield.processors.get_processor_class(name)[source]#
Return the registered class for
name, orNone.
- mesofield.processors.available_processors()[source]#
Sorted list of registered processor type names.
- mesofield.processors.build_processor(spec, camera=None, default_name=None)[source]#
Build a
FrameProcessorfrom a configspec.specis either a type-name string or a mapping with atypekey. Remaining mapping keys are forwarded to the processor constructor (plot,sampling_rate, and the recognized plot-styling kwargs).enabledis ignored here – callers decide whether to build a disabled entry.Raises
ValueErrorfor an unknown/missing type andTypeErrorfor a spec that is neither a string nor a mapping.