Using Gesture Recognition
The Tencent Effect SDK supports Hand Gesture Recognize starting from v1.0.23.
Enable Hand Gesture Module
Enable the hand gesture module when initializing the SDK.
import { ArSdk } from 'tencentcloud-webar';const sdk = new ArSdk({module: {beautify: true, // Beauty, Makeup, Face Effects modulehandGesture: true // Hand gesture recognition module},auth: { // The authentication informationlicenseKey: 'xxxxxxxxx',appId: 'xxx',authFunc: authFunc},camera: { // Pass in the camera parameterswidth: 1280,height: 720},beautify: {whiten: 0.1,dermabrasion: 0.3,eye: 0.2,chin: 0,lift: 0.1,shave: 0.2},…… // For more config settings, please refer to the「API Documentation」})
Listen for Gesture Changes.
After enabling gesture recognition, trigger
handGesture
when a gesture change occurs.// After enabling gesture recognition, it will trigger when a gesture change is detected.sdk.on('handGesture',(hands)=>{console.log('handGesture', hands) // Refer to the following "Hand Object Structure" for hands.…… // Other business code, such as setting effects through the SDK's setEffect interface, etc.})
Hand Object Structure
Hand: {gesture: string // Gesture names, optional values include: None, Thumb_Up, Thumb_Down, Victory, Pointing_Up, Open_Palm, ILoveYou, Closed_Fist.handedness: string // Recognized as left hand or right hand, values are Left, Right.}Hands: Array<Hand>
List of supported Gestures.
Hand gesture value | Detail |
None | No valid gesture recognized |
Thumb_Up | Thumbs up ![]() |
Thumb_Down | Thumb down ![]() |
Victory | victory ![]() |
Pointing_Up | pointing up ![]() |
Open_Palm | open palm ![]() |
ILoveYou | i love you ![]() |
Closed_Fist | close fist ![]() |