diff --git a/src/hand_landmark/detector.ts b/src/hand_landmark/detector.ts index bfa3a8c..8d3017b 100644 --- a/src/hand_landmark/detector.ts +++ b/src/hand_landmark/detector.ts @@ -7,6 +7,7 @@ import { export enum HandGesture { // 食指举起,移动鼠标 ONLY_INDEX_UP = "only_index_up", + INDEX_AND_THUMB_UP = "index_and_thumb_up" } interface HandLandmark { @@ -148,6 +149,8 @@ export class Detector { const gestureMap = new Map([ // 食指举起,移动鼠标 ["0,1,0,0,0", HandGesture.ONLY_INDEX_UP], + // 鼠标左键点击手势 + ["1,1,0,0,0", HandGesture.INDEX_AND_THUMB_UP], ]); if (gestureMap.has(fingerState)) { @@ -166,15 +169,19 @@ export class Detector { const hand = detection.rightHand ?? detection.leftHand; if (!hand) { - console.log("❌ 没检测到手"); + console.log("没检测到手"); return HandGesture.OTHER; } const gesture = Detector.getSingleHandGesture(hand); - console.log("🎯 当前手势状态是:", gesture); + console.log("当前手势状态是:", gesture); if (gesture === HandGesture.ONLY_INDEX_UP) { - console.log("✅ 识别到食指竖起!"); + console.log("识别到食指竖起!"); + } + + if (gesture === HandGesture.INDEX_AND_THUMB_UP) { + console.log("识别到食指和大拇指竖起!"); } return gesture; diff --git a/wavecontrol-test/src/hand_landmark/detector.ts b/wavecontrol-test/src/hand_landmark/detector.ts index 07bc495..8d3017b 100644 --- a/wavecontrol-test/src/hand_landmark/detector.ts +++ b/wavecontrol-test/src/hand_landmark/detector.ts @@ -7,6 +7,7 @@ import { export enum HandGesture { // 食指举起,移动鼠标 ONLY_INDEX_UP = "only_index_up", + INDEX_AND_THUMB_UP = "index_and_thumb_up" } interface HandLandmark { @@ -103,7 +104,6 @@ export class Detector { return detection; } - /** * 检测手指是否竖起 */ @@ -149,6 +149,8 @@ export class Detector { const gestureMap = new Map([ // 食指举起,移动鼠标 ["0,1,0,0,0", HandGesture.ONLY_INDEX_UP], + // 鼠标左键点击手势 + ["1,1,0,0,0", HandGesture.INDEX_AND_THUMB_UP], ]); if (gestureMap.has(fingerState)) { @@ -178,6 +180,10 @@ export class Detector { console.log("识别到食指竖起!"); } + if (gesture === HandGesture.INDEX_AND_THUMB_UP) { + console.log("识别到食指和大拇指竖起!"); + } + return gesture; }