Skip to content

詳細臉部偵測 ​

宣告實例 ​

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

python
detailed_face_detection = DetailedFaceDetection(0)
# 有多個實例時
detailed_face_detection_1 = DetailedFaceDetection(1)

參數 ​

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

設定相機 ​

設定用于詳細臉部偵測的相機。

device

參數 ​

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

Python ​

python
detailed_face_detection = DetailedFaceDetection(0)

detailed_face_detection.device('')

載入人臉模型 ​

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

load_model

參數 ​

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

Python ​

python
detailed_face_detection = DetailedFaceDetection(0)

detailed_face_detection.load_model(wait=True)

偵測一次人臉 ​

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

detect_once

參數 ​

(無)

Python ​

python
detailed_face_detection = DetailedFaceDetection(0)

detailed_face_detection.detect_once()

開始 / 停止連續臉部偵測 ​

連續跟蹤目前畫面中的人臉,並在畫面上標示出來。

detect_continuous

參數 ​

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

Python ​

python
detailed_face_detection = DetailedFaceDetection(0)

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

顯示結果 ​

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

display

參數 ​

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

Python ​

python
detailed_face_detection = DetailedFaceDetection(0)

detailed_face_detection.display(True)
detailed_face_detection.display(False)

人臉部位的坐標 ​

回傳人臉各部位的坐標。

face_data

參數 ​

名稱類別說明範圍 / 種類預設值
unit下拉選項人臉部位人臉(face), 左眼(left eye), 右眼(right eye), 嘴(mouth), 鼻子(nose), 上唇(upper lip), 下唇(lower lip), 左嘴角(left lip), 右嘴角(right lip), 左瞳孔(left pupil), 右瞳孔(right pupil)-
pos下拉選項坐標x, y-

Python ​

python
detailed_face_detection = DetailedFaceDetection(0)

detailed_face_detection.face('x')
detailed_face_detection.left_eye('y')
detailed_face_detection.upper_lip('x')
detailed_face_detection.right_pupil('y')

人臉部位矩形框資訊 ​

回傳人臉各部位區域矩形框的位置 / 大小值。

face_square

參數 ​

名稱類別說明範圍 / 種類預設值
unit下拉選項人臉部位人臉(face), 左眼(left eye), 右眼(right eye), 嘴(mouth)-
pos下拉選項矩形框資訊最小 x 坐標(min_x), 最大 x 坐標(max_x), 最小 y 坐標(min_y), 最大 y 坐標(max_y), 寬(width), 高(height), 面積(area)-

Python ​

python
detailed_face_detection = DetailedFaceDetection(0)

detailed_face_detection.face('min_x')
detailed_face_detection.left_eye('area')

兩個部位之間的距離 ​

回傳人臉兩處部位之間的距離。

distance

參數 ​

名稱類別說明範圍 / 種類預設值
unit1下拉選項第一個部位人臉部位名稱-
unit2下拉選項第二個部位人臉部位名稱-
type下拉選項距離種類距離(省略或 None), 水平距離(horizontal), 垂直距離(vertical)None

Python ​

python
detailed_face_detection = DetailedFaceDetection(0)

detailed_face_detection.get_distance('left_eye', 'right_eye')  # 距離
detailed_face_detection.get_distance('left_pupil', 'right_pupil', 'horizontal')  # 水平距離
detailed_face_detection.get_distance('upper_lip', 'lower_lip', 'vertical')  # 垂直距離

人臉模型載入狀態 ​

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

model_state

參數 ​

(無)

Python ​

python
detailed_face_detection = DetailedFaceDetection(0)

detailed_face_detection.model_state()

偵測到人臉? ​

是否找到了人臉

detected

參數 ​

(無)

Python ​

python
detailed_face_detection = DetailedFaceDetection(0)

detailed_face_detection.detected()