Skip to main content

ProcessState

Struct ProcessState 

Source
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: usize

Number of frames filtered since last reset.

Implementations§

Source§

impl ProcessState

Source

pub fn new(config: ProcessConfig) -> Self

Source

pub fn last_output(&self) -> Option<&NDArray>

The plugin’s last output array — C++ this->pArrays[0]. None until the first frame is emitted.

Source

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.

Source

pub fn save_flat_field(&mut self)

C++ NDPluginProcess::writeInt32(NDPluginProcessSaveFlatField) (NDPluginProcess.cpp:299-310) — the SaveBackground sequence above, on the flat-field buffer.

Source

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).

Source

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]

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more