Skip to content

meanShift

Motion and trackingfunctionOpenCV 5.0.0
import { meanShift } from '@banou/opencv-wasm'

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

ARGUMENTSprobImage, window, criteria
FUNCTIONmeanShift
RETURN TYPE[number, Rect]
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

example: samples/cpp/snippets/camshiftdemo.cpp An example using the mean-shift tracking algorithm Finds an object on a back projection image.

meanShift(probImage: Mat, window: Rect, criteria: TermCriteria): [number, Rect];
probImage

Back projection of the object histogram. See calcBackProject for details.

window

Input/output value, modified by the native operation. Initial search window.

criteria

Stop criteria for the iterative search algorithm. returns : Number of iterations CAMSHIFT took to converge. The function implements the iterative object search algorithm. It takes the input back projection of an object and the initial position. The mass center in window of the back projection image is computed and the search window center shifts to the mass center. The procedure is repeated until the specified number of iterations criteria.maxCount is done or until the window center shifts by less than criteria.epsilon. The algorithm is used inside CamShift and, unlike CamShift , the search window size or orientation do not change during the search. You can simply pass the output of calcBackProject to this function. But better results can be obtained if you pre-filter the back projection and remove the noise. For example, you can do this by retrieving connected components with findContours , throwing away contours with small area ( contourArea ), and rendering the remaining contours with drawContours.

Returns

The [number, Rect] result.

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.