Skip to main content

GestureModule

Class

Allows to detect hand gestures using machine learning algorithms.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported — SPECS only
  • SPECSFully supported
  • Camera Kit WebNot supported — SPECS only
  • Camera Kit MobileNot supported — SPECS only

Platform details

  • Snapchat — Not supported — SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — SPECS only.

  • Camera Kit Mobile — Not supported — SPECS only.

Allows to detect hand gestures using machine learning algorithms.

Index

Example

@component
export class PinchExample extends BaseScriptComponent {
private gestureModule: GestureModule = require('LensStudio:GestureModule');
onAwake() {
this.gestureModule
.getPinchDownEvent(GestureModule.HandType.Right)
.add((pinchDownArgs: PinchDownArgs) => {
print('Right Hand Pinch Down');
});

this.gestureModule
.getPinchUpEvent(GestureModule.HandType.Right)
.add((pinchUpArgs: PinchUpArgs) => {
print('Right Hand Pinch Up');
});

this.gestureModule
.getFilteredPinchDownEvent(GestureModule.Handtype.Right)
.add((pinchDownArgs: PinchDownArgs) => {
print('Right Hand filtered Pinch Down');
});

this.gestureModule
.getFilteredPinchUpEvent(GestureModule.Handtype.Right)
.add((pinchUpArgs: PinchUpArgs) => {
print('Right Hand filtered Pinch Up');
});

this.gestureModule
.getPinchStrengthEvent(GestureModule.HandType.Right)
.add((pinchStrengthArgs: PinchStrengthArgs) => {
print('Right Hand Pinch Strength: ' + pinchStrengthArgs.strength);
});

this.gestureModule
.getGrabBeginEvent(GestureModule.HandType.Right)
.add((grabBeginArgs: GrabBeginArgs) => {
print('Right Hand Grab Begin');
});
}
}

Extends

Properties

name

name: string

The name of the Asset in Lens Studio.

Default Value

""

Inherited from

Asset.name


uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Asset.uniqueIdentifier

Methods

getFilteredPinchDownEvent()

getFilteredPinchDownEvent(handType): event1<PinchDownArgs, void>

SPECS only

Triggered when the thumb and index fingers of the hand in view are pinched together. Compared to getPinchDownEvent, this event is more robust when moving the hand.

Parameters

ParameterType
handTypeHandType

Returns

event1<PinchDownArgs, void>


getFilteredPinchUpEvent()

getFilteredPinchUpEvent(handType): event1<PinchUpArgs, void>

SPECS only

Triggered when the thumb and index fingers of the hand in view are separated after being pinched together. Compared to getPinchUpEvent, this event is more robust when moving the hand.

Parameters

ParameterType
handTypeHandType

Returns

event1<PinchUpArgs, void>


getGrabBeginEvent()

getGrabBeginEvent(handType): event1<GrabBeginArgs, void>

SPECS only

Triggered when the hand in view starts performing a grab pose, enabling interactions such as grabbing virtual objects or making a fist.

Parameters

ParameterType
handTypeHandType

Returns

event1<GrabBeginArgs, void>


getGrabEndEvent()

getGrabEndEvent(handType): event1<GrabEndArgs, void>

SPECS only

Triggered when the hand in view ends performing a grab pose and opens the hand, disabling interactions such as grabbing virtual objects or making a fist.

Parameters

ParameterType
handTypeHandType

Returns

event1<GrabEndArgs, void>


getIsPhoneInHandBeginEvent()

getIsPhoneInHandBeginEvent(handType): event1<IsPhoneInHandBeginArgs, void>

SPECS only

Triggered when a phone is detected in a hand. Note: Only smartphone-like objects are detected.

Details: The event indicates that the state of a hand not holding a phone has changed to a hand holding a phone. If a Lens contains a GestureModel and has subscribed to getIsPhoneInHandBeginEvent, an initial event is always sent at the start of the Lens if a hand already holds a phone.

For technical reasons, if a Lens does not initially subscribe to getIsPhoneInHandBeginEvent, but subscribes at a later time, no initial event will be sent after subscription.

Parameters

ParameterType
handTypeHandType

Returns

event1<IsPhoneInHandBeginArgs, void>


getIsPhoneInHandEndEvent()

getIsPhoneInHandEndEvent(handType): event1<IsPhoneInHandEndArgs, void>

SPECS only

Triggered when a phone is no longer detected in a hand. Note: Only smartphone-like objects are considered.

Details: The event indicates that the state of a hand holding a phone has changed to a hand not holding a phone. If a Lens contains a GestureModel and has subscribed to getIsPhoneInHandEndEvent, an initial event is always sent at the start of the Lens if a hand does not hold a phone.

For technical reasons, if a Lens does not initially subscribe to getIsPhoneInHandEndEvent, but subscribes at a later time, no initial event will be sent after subscription.

Parameters

ParameterType
handTypeHandType

Returns

event1<IsPhoneInHandEndArgs, void>


getPalmTapDownEvent()

getPalmTapDownEvent(handType): event1<PalmTapDownArgs, void>

SPECS only

Triggered when the index finger of one hand taps the palm of the opposite hand. Specifically, a right-hand palm tap is recognized when the right index finger touches the left palm, and a left-hand palm tap when the left index finger touches the right palm.

Parameters

ParameterType
handTypeHandType

Returns

event1<PalmTapDownArgs, void>


getPalmTapUpEvent()

getPalmTapUpEvent(handType): event1<PalmTapUpArgs, void>

SPECS only

Triggered when the left index finger from one hand lifts from the palm on the opposite hand after touching. Currently, only the palm tap to the left hand is supported.

Parameters

ParameterType
handTypeHandType

Returns

event1<PalmTapUpArgs, void>


getPinchDownEvent()

getPinchDownEvent(handType): event1<PinchDownArgs, void>

SPECS only

Triggered when the thumb and index fingers of the hand in view are pinched together.

Parameters

ParameterType
handTypeHandType

Returns

event1<PinchDownArgs, void>


getPinchStrengthEvent()

getPinchStrengthEvent(handType): event1<PinchStrengthArgs, void>

SPECS only

Get the strength of a pinch between the thumb and index fingers of the hand in view.

Parameters

ParameterType
handTypeHandType

Returns

event1<PinchStrengthArgs, void>


getPinchUpEvent()

getPinchUpEvent(handType): event1<PinchUpArgs, void>

SPECS only

Triggered when the thumb and index fingers of the hand in view are separated after being pinched together.

Parameters

ParameterType
handTypeHandType

Returns

event1<PinchUpArgs, void>


getTargetingDataEvent()

getTargetingDataEvent(handType): event1<TargetingDataArgs, void>

SPECS only

Triggered when the user has an intent to target a digital content in space.

Parameters

ParameterType
handTypeHandType

Returns

event1<TargetingDataArgs, void>


getTypeName()

static getTypeName(): TypeName<GestureModule>

SPECS only

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<GestureModule>

Overrides

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Asset.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Asset.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Asset.isSame

See also

Gesture Module guide.

Nested types

Enumerations

EnumerationDescription
HandTypeThe hand used in gesture detection with GestureModule.