MaskΒΆ

Methods:

class com::leapmotion::leap::Mask

Note: This class is an experimental API for internal use only.

It may be removed without warning.

A bitmap mask defining areas of an image in which a finger or part of a hand is in front of the tracked quad. The mask is a subset of the camera image containing a the region including the quad. Pixels in the mask representing the hand have the value 255. Pixels in the rest of the mask have the value 0.

Two masks are provided for every Leap Motion frame. The mask with the id of 0 is for the left image. The right image has id 1.

The mask corresponds to the uncorrected image from the camera sensor. If you correct the image for distortion before displaying it, you should also correct the mask.

Since
2.2.6

Public Functions

byte[] data()

The mask data.

The mask data is a set of 8-bit intensity values. The buffer is image.width() * image.height() bytes long. Areas of the mask which contain part of a hand or finger covering the quad are assigned the value 255. The rest of the mask is assigned the value 0.

Mask leftMask = quad.masks().get(0);
byte[] maskPixels = leftMask.data();
Since
2.2.5

boolean equals(Mask arg0)

Compares two Mask objects for equality.

Since
2.2.6

int height()

The height of the mask in Image pixels.

Mask leftMask = quad.masks().get(0);
int height = leftMask.height();
Since
2.2.6

int id()

An id indicating whether the mask goes with the left (0) or right (1) image.

Mask leftMask = quad.masks().get(0);
int id = leftMask.id();
Since
2.2.6

boolean isValid()

Reports whether this is a valid Mask object.

Since
2.2.6

Mask()

Constructs a new Mask object.

Do not use. Get Mask objects from TrackedQuad.

Controller controller = new Controller();
TrackedQuad quad = controller.trackedQuad();
Mask leftMask = quad.masks().get(0);
Mask rightMask = quad.masks().get(1);
Controller controller = new Controller();
Frame frame = controller.frame();
TrackedQuad quad = frame.trackedQuad();
Mask leftMask = quad.masks().get(0);
Mask rightMask = quad.masks().get(1);
Since
2.2.6

int offsetX()

The offset of the mask from the left edge of the Image in pixels.

Mask leftMask = quad.masks().get(0);
int x = leftMask.offsetX();
Since
2.2.6

int offsetY()

The offset of the mask from the top edge of the Image in pixels.

Mask leftMask = quad.masks().get(0);
int y = leftMask.offsetY();
Since
2.2.6

long sequenceId()

An id value based on the sequence in which the mask is produced.

Corresponds to the Image sequence id.

Mask leftMask = quad.masks().get(0);
long sequenceID = leftMask.sequenceId();
Since
2.2.6

int width()

The width of the mask in Image pixels.

Mask leftMask = quad.masks().get(0);
int width = leftMask.width();
Since
2.2.6

Public Static Functions

Mask invalid()

An invalid Mask object.

Since
2.2.6