@@ -39,9 +39,10 @@ class Handpose extends EventEmitter {
39
39
async loadModel ( ) {
40
40
const pipeline = handPoseDetection . SupportedModels . MediaPipeHands ;
41
41
const modelConfig = {
42
- runtime : "mediapipe" , // use MediaPipe runtime by default
42
+ maxHands : this . config ?. maxHands ?? 2 , // detect up to 2 hands by default
43
+ runtime : this . config ?. runtime ?? "mediapipe" , // use MediaPipe runtime by default
44
+ modelType : this . config ?. modelType ?? "full" , // use full version of the model by default
43
45
solutionPath : "https://cdn.jsdelivr.net/npm/@mediapipe/hands" , // fetch model from mediapipe server
44
- ...this . config ,
45
46
} ;
46
47
47
48
this . model = await handPoseDetection . createDetector ( pipeline , modelConfig ) ;
@@ -66,10 +67,11 @@ class Handpose extends EventEmitter {
66
67
throw new Error ( "No input image found." ) ;
67
68
}
68
69
await mediaReady ( image , false ) ;
69
- const { flipHorizontal } = this . config ;
70
- const predictions = await this . model . estimateHands ( image , {
71
- flipHorizontal,
72
- } ) ;
70
+ const options = {
71
+ flipHorizontal : this . config ?. flipHorizontal ?? false , // do not horizontally flip the prediction by default
72
+ } ;
73
+ const predictions = await this . model . estimateHands ( image , options ) ;
74
+ //TODO: customize the output for easier use
73
75
const result = predictions ;
74
76
75
77
this . emit ( "hand" , result ) ;
0 commit comments