Skip to main content

TensorMath.solvePnP

Function

Estimates the object pose given a set of object points (inObjectPoints), their corresponding image projections (inImagePoints), and the intrinsic camera matr…

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

solvePnP(inObjectPoints, inImagePoints, imagePointsShape, transform, flags, outRotTrans): boolean

Estimates the object pose given a set of object points (inObjectPoints), their corresponding image projections (inImagePoints), and the intrinsic camera matrix (transform).

inObjectPoints - Float32Array of size (point count * 3). 3D points of the object

inImagePoints - Float32Array of size (point count * 2). 2D points which are projections of the points in inObjectPoints, with some applied transformation we are attempting to find

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

transform - Intrinsic camera matrix

flags - Currently unused, can be left as 0. Further functionality may be added in the future.

outRotTrans - Float32Array of size 6 where results are written. Describes object transformation:

vec3(outRotTrans[0], outRotTrans[1], outRotTrans[2]) - object rotation in Rodrigues format

vec3(outRotTrans[3], outRotTrans[4], outRotTrans[5]) - object position in 3D space

Parameters

ParameterType
inObjectPointsFloat32Array
inImagePointsFloat32Array
imagePointsShapevec3
transformmat3
flagsnumber
outRotTransFloat32Array

Returns

boolean