Skip to content

motempl_updateMotionHistory

optflowfunctionOpenCV 5.0.0
import { motempl_updateMotionHistory } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSsilhouette, mhi, timestamp, duration
FUNCTIONmotempl_updateMotionHistory
RETURN TYPEvoid
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Updates the motion history image by a moving silhouette.

motempl_updateMotionHistory(silhouette: Mat, mhi: Mat, timestamp: number, duration: number): void;
silhouette

Silhouette mask that has non-zero pixels where the motion occurs.

mhi

Input/output value, modified by the native operation. Motion history image that is updated by the function (single-channel, 32-bit floating-point).

timestamp

Current time in milliseconds or other units.

duration

Maximal duration of the motion track in the same units as timestamp .

The function updates the motion history image as follows:

\texttt{mhi} (x,y)= \forkthree{\texttt{timestamp}}{if \(\texttt{silhouette}(x,y) \ne 0\)}{0}{if \(\texttt{silhouette}(x,y) = 0\) and \(\texttt{mhi} < (\texttt{timestamp} - \texttt{duration})\)}{\texttt{mhi}(x,y)}{otherwise}

That is, MHI pixels where the motion occurs are set to the current timestamp , while the pixels where the motion happened last time a long time ago are cleared.

The function, together with calcMotionGradient and calcGlobalOrientation , implements a motion templates technique described in [Davis97] and [Bradski00] .

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.