pub struct ProcessState {
pub config: ProcessConfig,
pub background: Option<Vec<f64>>,
pub flat_field: Option<Vec<f64>>,
pub filter_state: Option<Vec<f64>>,
pub num_filtered: usize,
/* private fields */
}Expand description
State for the process plugin (holds background, flat field, and filter state).
Matches the C++ NDPluginProcess which uses a single pFilter array.
Fields§
§config: ProcessConfig§background: Option<Vec<f64>>§flat_field: Option<Vec<f64>>§filter_state: Option<Vec<f64>>Single filter buffer (equivalent to C++ pFilter).
Invariant (NDPluginProcess.cpp:182-187): this buffer is dropped only when its element count no longer matches the incoming frame. No parameter write may free it — a requested reset re-seeds the contents in place via the RC coefficients, it does not discard them.
num_filtered: usizeNumber of frames filtered since last reset.
Implementations§
Source§impl ProcessState
impl ProcessState
pub fn new(config: ProcessConfig) -> Self
Sourcepub fn last_output(&self) -> Option<&NDArray>
pub fn last_output(&self) -> Option<&NDArray>
The plugin’s last output array — C++ this->pArrays[0]. None until the
first frame is emitted.
Sourcepub fn save_background(&mut self)
pub fn save_background(&mut self)
C++ NDPluginProcess::writeInt32(NDPluginProcessSaveBackground)
(NDPluginProcess.cpp:287-298), performed synchronously on the parameter
write, not deferred to the next frame:
setIntegerParam(SaveBackground, 0);
if (pBackground) pBackground->release();
pBackground = NULL;
setIntegerParam(ValidBackground, 0);
if (pArrays[0]) {
convert(pArrays[0], &pBackground, NDFloat64);
nBackgroundElements = arrayInfo.nElements;
setIntegerParam(ValidBackground, 1);
}So the old buffer is dropped and ValidBackground cleared even when there is no array to save from, and the source is the last OUTPUT array — the one this plugin already emitted, in the output data type.
Sourcepub fn save_flat_field(&mut self)
pub fn save_flat_field(&mut self)
C++ NDPluginProcess::writeInt32(NDPluginProcessSaveFlatField)
(NDPluginProcess.cpp:299-310) — the SaveBackground sequence above, on the
flat-field buffer.
Sourcepub fn auto_offset_scale(&mut self, array: &NDArray)
pub fn auto_offset_scale(&mut self, array: &NDArray)
Auto-calculate offset and scale matching C++ NDPluginProcess.
C++: scale = maxScale / (maxValue - minValue); offset = -minValue; Also enables offset/scale processing and clipping (matching C++ lines 238-249).
Sourcepub fn apply_filter_type(&mut self, filter_type: i32)
pub fn apply_filter_type(&mut self, filter_type: i32)
Apply a named filter type preset, setting the FC/OC/RC coefficients.
Uses the C++ coefficient scheme where: O1 = oScale * (oc[0] + oc[1]/N), O2 = oScale * (oc[2] + oc[3]/N) F1 = fScale * (fc[0] + fc[1]/N), F2 = fScale * (fc[2] + fc[3]/N) data[i] = oOffset + O1filter[i] + O2data[i] filter[i] = fOffset + F1filter[i] + F2data[i]
Sourcepub fn reset_filter(&mut self)
pub fn reset_filter(&mut self)
Request a filter reset on the next processed frame.
This is the ResetFilter parameter write. C only clears the PV
(NDPluginProcess.cpp:91-93) and lets processCallbacks act on the local
flag; pFilter keeps its contents, so the reset formula at :204-209
(newFilter = rOffset + rc1*filter[i] + rc2*data[i]) evaluates against
the previous filter buffer. Freeing the buffer here would make
filter[i] == data[i] on the next frame and change the reinitialized
value whenever RC1 != 0.
Sourcepub fn process(&mut self, src: &NDArray) -> Option<NDArray>
pub fn process(&mut self, src: &NDArray) -> Option<NDArray>
Process an array through the configured pipeline. Process one input array.
Returns Some(output) for a normal frame, or None when the frame is
suppressed by the recursive-filter filter_callbacks setting (C++ sets
doCallbacks = 0 and the frame is dropped — nothing goes downstream).
Auto Trait Implementations§
impl !RefUnwindSafe for ProcessState
impl !UnwindSafe for ProcessState
impl Freeze for ProcessState
impl Send for ProcessState
impl Sync for ProcessState
impl Unpin for ProcessState
impl UnsafeUnpin for ProcessState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more