Skip to main content

TensorMath.opticalFlow

Function

Stabilizes image objects between two consecutive frames caused by camera or object movement.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

opticalFlow(prevGrayscale, grayscale, textureShape, prevPoints, points, pointsShape, winSize, maxLevel, maxCount, epsilon): void

Stabilizes image objects between two consecutive frames caused by camera or object movement. Results are written to the points array.

prevGrayscale - Uint8Array of size (width * height). Grayscale data of previous frame

grayscale - Uint8Array of size (width * height). Grayscale data of current frame

textureShape - Should be {width, height, 1}

prevPoints - Float32Array of size (point count * 2). Positions of 2D points on the previous frame

points - Float32Array of size (point count * 2). Results are written here - positions of 2D points on the current frame

pointsShape - Should be {2, point count, 1}

winSize - Size of the search window for each pyramid level

maxLevel - Maximal pyramid level number, with zero based index

maxCount - Terminate if iteration count exceeds maxCount

epsilon - Terminate if window movement is less than epsilon

Parameters

ParameterType
prevGrayscaleUint8Array
grayscaleUint8Array
textureShapevec3
prevPointsFloat32Array
pointsFloat32Array
pointsShapevec3
winSizevec2
maxLevelnumber
maxCountnumber
epsilonnumber

Returns

void