Skip to main content

TensorMath.getContour

Function

Looks for contour points in a grayscale texture, or any one-channel tensor.

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

getContour(grayscaledTexture, textureShape, threshold, winSize, maxNearCount, outTensor): number

Looks for contour points in a grayscale texture, or any one-channel tensor.

grayscaledTexture - Float32Array of size (width * height). Grayscale texture or one-channel tensor to evaluate

textureShape - Should be {width, height, 1}

threshold - Quality value threshold for found contour points

Each contour point found must satisfy these conditions:

  1. The point's quality value should be >= threshold

  2. The number of points which have values < threshold and lie in the rectangle with left corner vec2(x-winSize, y-winSize) and right corner vec2(x+winSize-1, y+winSize-1) should be <= maxNearCount

outTensor - Float32Array where results are written. Found contour points are written in the format: x0, y0, x1, y1, etc. The number of points found will not exceed outTensor's size / 2.

Parameters

ParameterType
grayscaledTextureFloat32Array
textureShapevec3
thresholdnumber
winSizenumber
maxNearCountnumber
outTensorFloat32Array

Returns

number