Skip to content

motempl_calcMotionGradient

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

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

ARGUMENTSmhi, mask, orientation, delta1
FUNCTIONmotempl_calcMotionGradient
RETURN TYPEvoid
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Calculates a gradient orientation of a motion history image.

Note: - (Python) An example on how to perform a motion template technique can be found at opencv_source_code/samples/python2/motempl.py

motempl_calcMotionGradient(mhi: Mat, mask: Mat, orientation: Mat, delta1: number, delta2: number, apertureSize: number): void;
2 available overloads
motempl_calcMotionGradient(mhi: Mat, mask: Mat, orientation: Mat, delta1: number, delta2: number): void;
motempl_calcMotionGradient(mhi: Mat, mask: Mat, orientation: Mat, delta1: number, delta2: number, apertureSize: number): void;
mhi

Motion history single-channel floating-point image.

mask

Output destination, filled by the native operation. Output mask image that has the type CV_8UC1 and the same size as mhi . Its non-zero elements mark pixels where the motion gradient data is correct.

orientation

Output destination, filled by the native operation. Output motion gradient orientation image that has the same type and the same size as mhi . Each pixel of the image is a motion orientation, from 0 to 360 degrees.

delta1

Minimal (or maximal) allowed difference between mhi values within a pixel neighborhood.

delta2

Maximal (or minimal) allowed difference between mhi values within a pixel neighborhood. That is, the function finds the minimum ( m(x,y) ) and maximum ( M(x,y) ) mhi values over 3 \times 3 neighborhood of each pixel and marks the motion orientation at (x, y) as valid only if

\min ( \texttt{delta1}  ,  \texttt{delta2}  )  \le  M(x,y)-m(x,y)  \le   \max ( \texttt{delta1}  , \texttt{delta2} ).
apertureSize

Aperture size of the Sobel operator.

The function calculates a gradient orientation at each pixel (x, y) as:

\texttt{orientation} (x,y)= \arctan{\frac{d\texttt{mhi}/dy}{d\texttt{mhi}/dx}}

In fact, fastAtan2 and phase are used so that the computed angle is measured in degrees and covers the full range 0..360. Also, the mask is filled to indicate pixels where the computed angle is valid.

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.