Skip to content

手部偵測 ​

宣告實例 ​

把手部偵測(HandDetection) 積木新增到工作區後,Python 程式碼中會自動插入下面這樣的實例宣告:

python
hand_detection = HandDetection(0)
# 有多個實例時
hand_detection_1 = HandDetection(1)

參數 ​

名稱類別說明範圍 / 種類預設值
index下拉選項實例編號(從 0 開始)0 以上的整數0

設定相機 ​

設定用于手部偵測的相機。

device

參數 ​

名稱類別說明範圍 / 種類預設值
unit下拉選項相機設備名稱系統相機標籤-

Python ​

python
hand_detection = HandDetection(0)

hand_detection.device('')

載入手部模型 ​

載入訓練好的手部模型。要使用「手部偵測」模組的功能,必須先完成這一步。

load_model

參數 ​

名稱類別說明範圍 / 種類預設值
wait核取方塊是否等待載入完成TRUE / FALSETRUE

Python ​

python
hand_detection = HandDetection(0)

hand_detection.load_model(wait=True)

設定偵測目標 ​

決定偵測手部時,是以單手為准還是以雙手為准。

max_hands

參數 ​

名稱類別說明範圍 / 種類預設值
unit下拉選項手的數量單手(one), 雙手(both)-

Python ​

python
hand_detection = HandDetection(0)

hand_detection.max_hands('one')
hand_detection.max_hands('both')

偵測一次手部 ​

找出目前畫面中的手,只標示一次。

detect_once

參數 ​

(無)

Python ​

python
hand_detection = HandDetection(0)

hand_detection.detect_once()

開始 / 停止持續手部偵測 ​

持續跟蹤目前畫面中的手,並在畫面上標示出來。

detect_continuous

參數 ​

名稱類別說明範圍 / 種類預設值
unit下拉選項動作開始(start), 停止(stop)-

Python ​

python
hand_detection = HandDetection(0)

# unit = "start"
hand_detection.detect_continuous()
# unit = "stop"
hand_detection.stop()

顯示結果 ​

決定是否在相機畫面上顯示手部偵測的結果。

display

參數 ​

名稱類別說明範圍 / 種類預設值
on下拉選項顯示 ON / OFF顯示(on=True), 隱藏(off=False)TRUE

Python ​

python
hand_detection = HandDetection(0)

hand_detection.display(True)
hand_detection.display(False)

手部部位的位置 ​

回傳指定手的手掌 / 手腕位置資訊。

hand_data

參數 ​

名稱類別說明範圍 / 種類預設值
side下拉選項手的方向左側(left), 右側(right)-
unit下拉選項手部部位手掌(palm), 手腕(wrist)-
pos下拉選項坐標 / 大小種類x, y-

Python ​

python
hand_detection = HandDetection(0)

hand_detection.hand('left', 'palm', 'x')
hand_detection.hand('right', 'wrist', 'y')
hand_detection.hand('left', 'hand', 'min_x')
hand_detection.hand('right', 'palm', 'width')

手指指節的位置 ​

回傳指定手指的關節坐標。

joint_data

參數 ​

名稱類別說明範圍 / 種類預設值
side下拉選項手的方向左側(left), 右側(right)-
unit下拉選項手指拇指(thumb), 食指(index), 中指(middle), 無名指(ring), 小指(pinky)-
joint下拉選項指節位置第一指節(first), 第二指節(second), 第三指節(third), 指尖(last)-
pos下拉選項坐標x, y-

Python ​

python
hand_detection = HandDetection(0)

hand_detection.finger('left', 'index', 'first', 'x')
hand_detection.finger('right', 'thumb', 'last', 'y')

手部矩形資訊 ​

回傳指定手部區域矩形的位置 / 大小值。

hand_square

參數 ​

名稱類別說明範圍 / 種類預設值
side下拉選項手的方向左側(left), 右側(right)-
unit下拉選項手部部位手(hand), 手掌(palm)-
pos下拉選項矩形資訊最小 x 坐標(min_x), 最大 x 坐標(max_x), 最小 y 坐標(min_y), 最大 y 坐標(max_y), 寬(width), 高(height), 面積(area)-

Python ​

python
hand_detection = HandDetection(0)

hand_detection.hand('left', 'hand', 'min_x')
hand_detection.hand('right', 'palm', 'width')

手與手之間的距離 ​

回傳兩個手部部位之間的距離。

hand_to_hand_distance

參數 ​

名稱類別說明範圍 / 種類預設值
unit1輸入值(字串)第一個手部部位手: 'side_unit' (例: 'left_palm')。side=left/right, unit=palm/wrist/hand-
unit2輸入值(字串)第二個手部部位手: 'side_unit' (例: 'right_palm')。side=left/right, unit=palm/wrist/hand-
type下拉選項距離種類距離(省略或 None), 水平距離(horizontal), 垂直距離(vertical)None

Python ​

python
hand_detection = HandDetection(0)

# 手 ↔ 手 / 距離
hand_detection.get_distance('left_palm', 'right_palm')

手與手指之間的距離 ​

回傳手部部位與手指指節之間的距離。

hand_to_joint_distance

參數 ​

名稱類別說明範圍 / 種類預設值
unit1輸入值(字串)第一個部位手: 'side_unit' (例: 'left_palm')。side=left/right, unit=palm/wrist/hand-
unit2輸入值(字串)第二個部位手指: 'side_unit_joint' (例: 'right_index_first')。unit=thumb/index/middle/ring/pinky, joint=first/second/third/last-
type下拉選項距離種類距離(省略或 None), 水平距離(horizontal), 垂直距離(vertical)None

Python ​

python
hand_detection = HandDetection(0)

# 手 ↔ 手指指節 / 水平距離
hand_detection.get_distance('left_palm', 'right_index_first')

手指與手指之間的距離 ​

回傳兩個手指指節之間的距離。

joint_to_joint_distance

參數 ​

名稱類別說明範圍 / 種類預設值
unit1輸入值(字串)第一個部位手指: 'side_unit_joint' (例: 'left_thumb_last')。unit=thumb/index/middle/ring/pinky, joint=first/second/third/last-
unit2輸入值(字串)第二個部位手指: 'side_unit_joint' (例: 'right_index_first')。unit=thumb/index/middle/ring/pinky, joint=first/second/third/last-
type下拉選項距離種類距離(省略或 None), 水平距離(horizontal), 垂直距離(vertical)None

Python ​

python
hand_detection = HandDetection(0)

# 手指指節 ↔ 手指指節 / 垂直距離
hand_detection.get_distance('left_thumb_last', 'right_index_first', 'vertical')

手部模型載入狀態 ​

回傳手部模型的載入狀態。
還沒有載入時回傳 0,正在載入時回傳 1,載入完成時回傳 2。

model_state

參數 ​

(無)

Python ​

python
hand_detection = HandDetection(0)

hand_detection.model_state()

偵測到手部? ​

是否找到了手

detected

參數 ​

(無)

Python ​

python
hand_detection = HandDetection(0)

hand_detection.detected()