# Multiple Hand Gesture Control
## 安裝套件
### 開啟命令列視窗

### 安裝 OpenCV
OpenCV 是個影像處理的套件,可以控制攝影機,擷取畫面,針對影像做特效處理,在影像上做圖…等功能。
> pip install opencv-python

### 安裝 mediapipe
mediapipe 是 Google 所提供的一套深度學習模型。此模型提供了臉部追蹤,姿勢擷取,手勢擷取…等功能。
安裝指令
> pip install mediapipe

### 安裝 cvzone
cvzone 是一套基於 Mediapipe 的套件,它讓我們在使用 Mediapipe 上更為方便。
安裝指令
> pip install cvzone

### 安裝 Numpy
Numpy是Python語言的一個擴充程式庫。支援高階大量的維度陣列與矩陣運算,此外也針對陣列運算提供大量的數學函式庫。
安裝指令
> pip install numpy1
>
> 
## 設定相機
```python=
import cv2 #指定攝影機
from cvzone.HandTrackingModule import HandDetector #手跟蹤模組
import cvzone
cap = cv2.VideoCapture(0)
# 產生一個手部骨架偵測器
detector = HandDetector(detectionCon=0.8, maxHands=2)
```
### 抓取骨架的節點
```python=
while True: # 不斷地監控相機,並補抓影像
success, img = cap.read()
# success 中會指定有沒有成功地抓到資料, True 就是成功,False 就是失敗
# img 如果成功,那 img 中就是目前攝影機的影像
hands, img = detector.findHands(img) #with drawing
# hands = detector.findHands(img, draw=False)
if hands:
# Hand 1
hand1 = hands[0]
lmList = hand1["lmList"] #List of 21 Landmarks Points
bbox1 = hand1["bbox"] #Bounding box info x,y,w,h
centerPoint1 = hand1["center"] #center of the hand cx,cy
handType1 = hand1["type"] #Hand Type Left orRight
#print (len(lmList1),lmList1)
#print(bbox1)
#print(centerPoint1)
# fingers1 = detector.fingersUP(hand1)
#length, info, img = detector.findDistance(lmList[8], lmList[12], img) #with draw
#length, info = detector.findDistance(lmList[8], lmList[12], img) #no draw
if len(hands) == 2:
hand2 = hands[1]
lmList2 = hand2["lmList"] #List of 21 Landmarks Points
bbox2 = hand2["bbox"] #Bounding box info x,y,w,h
centerPoint2 = hand2["center"] #center of the hand cx,cy
handType2 = hand2["type"] #Hand Type Left orRight
#fingers2 = detector.fingersUP(hand2)
#print(fingers1,fingers2)
#length, info, img = detector.findDistance(lmList[8], lmList[8], img) #with draw
length, info, img = detector.findDistance(centerPoint1, centerPoint2, img) #with draw
cv2.imshow("Image", img)
cv2.waitKey(1)
```
### 手部骨架關節點
底下是 [Mediapipe 官方網站](https://google.github.io/mediapipe/solutions/hands.html)給出的的手部骨架關鍵節點 (landmark) 的資訊
