Skip to content

kinfu_KinFu

rgbdclassOpenCV 5.0.0
import { kinfu_KinFu } from '@banou/opencv-wasm'

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

ARGUMENTSConstructor or factory
CLASSkinfu_KinFu
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods.

KinectFusion implementation

This class implements a 3d reconstruction algorithm described in [kinectfusion] paper.

It takes a sequence of depth images taken from depth sensor (or any depth images source such as stereo camera matching algorithm or even raymarching renderer). The output can be obtained as a vector of points and their normals or can be Phong-rendered from given camera pose.

An internal representation of a model is a voxel cuboid that keeps TSDF values which are a sort of distances to the surface (for details read the [kinectfusion] article about TSDF). There is no interface to that representation yet.

KinFu uses OpenCL acceleration automatically if available. To enable or disable it explicitly use cv::setUseOptimized() or cv::ocl::setUseOpenCL().

This implementation is based on kinfu-remake.

Note that the KinectFusion algorithm was patented and its use may be restricted by the list of patents mentioned in README.md file in this module directory.

That's why you need to set the OPENCV_ENABLE_NONFREE option in CMake to use KinectFusion.

Constructors and members

static create

Create an owned kinfu_KinFu instance with the supplied configuration.

KinectFusion implementation

create(_params: kinfu_Params | null): kinfu_KinFu | null;
_params

params argument (kinfu_Params | null).

Returns

The kinfu_KinFu | null result.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

render

Renders a volume into an image

  Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
  Light pose is fixed in KinFu params.
render(image: Mat): void;
image

Output destination, filled by the native operation. resulting image

render1

Renders a volume into an image

  Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
  Light pose is fixed in KinFu params.
render1(image: Mat, cameraPose: Matx44f): void;
image

Output destination, filled by the native operation. resulting image

cameraPose

pose of camera to render from. If empty then render from current pose which is a last frame camera pose.

getCloud

Gets points and normals of current 3d mesh

  The order of normals corresponds to order of points.
  The order of points is undefined.
getCloud(points: Mat, normals: Mat): void;
points

Output destination, filled by the native operation. vector of points which are 4-float vectors

normals

Output destination, filled by the native operation. vector of normals which are 4-float vectors

getPoints

Gets points of current 3d mesh

 The order of points is undefined.
getPoints(points: Mat): void;
points

Output destination, filled by the native operation. vector of points which are 4-float vectors

getNormals

Calculates normals for given points

getNormals(points: Mat, normals: Mat): void;
points

input vector of points which are 4-float vectors

normals

Output destination, filled by the native operation. output vector of corresponding normals which are 4-float vectors

reset

Resets the algorithm

Clears current model and resets a pose.
reset(): void;

update

Process next depth frame

  Integrates depth into voxel space with respect to its ICP-calculated pose.
  Input image is converted to CV_32F internally if has another type.
update(depth: Mat): boolean;
depth

one-channel image which size and depth scale is described in algorithm's parameters

Returns

true if succeeded to align new frame with current scene, false if opposite

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.