Skip to content

臉部表情 ​

宣告實例 ​

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

python
face_expression = FaceExpression(0)
# 有多個實例時
face_expression_1 = FaceExpression(1)

參數 ​

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

設定相機 ​

設定用于識別年齡、性別和表情的相機。

device

參數 ​

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

Python ​

python
face_expression = FaceExpression(0)

face_expression.device('')

載入人臉表情模型 ​

載入訓練好的年齡、性別和表情模型。要使用「臉部表情」模組的功能,必須先完成這一步。

load_model

參數 ​

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

Python ​

python
face_expression = FaceExpression(0)

face_expression.load_model(wait=True)

偵測一次人臉表情 ​

分析目前畫面中的人臉,把預測出的年齡、性別和表情只顯示一次。

detect_once

參數 ​

(無)

Python ​

python
face_expression = FaceExpression(0)

face_expression.detect_once()

開始 / 停止持續人臉表情偵測 ​

持續分析目前畫面中的人臉,把預測出的年齡、性別和表情顯示在畫面上。

detect_continuous

參數 ​

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

Python ​

python
face_expression = FaceExpression(0)

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

顯示結果 ​

決定是否在相機畫面上顯示年齡、性別和表情的識別結果。

display

參數 ​

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

Python ​

python
face_expression = FaceExpression(0)

face_expression.display(True)
face_expression.display(False)

年齡 ​

年齡

age

參數 ​

(無)

Python ​

python
face_expression = FaceExpression(0)

face_expression.age()

性別 ​

性別

gender

參數 ​

(無)

Python ​

python
face_expression = FaceExpression(0)

face_expression.gender()

表情 ​

表情

expression

參數 ​

(無)

Python ​

python
face_expression = FaceExpression(0)

face_expression.expression()

偵測到性別? ​

是否識別出了性別

gender_detected

參數 ​

(無)

Python ​

python
face_expression = FaceExpression(0)

face_expression.gender_detected()

性別是特定值? ​

回傳識別出的性別是否與指定的值一致,結果為 true(True) / false(False)。

gender_check

參數 ​

名稱類別說明範圍 / 種類預設值
unit下拉選項性別男性(male), 女性(female)-

Python ​

python
face_expression = FaceExpression(0)

face_expression.is_gender('male')
face_expression.is_gender('female')

性別的信心度 ​

是所選性別的機率(信心度)

gender_confidence

參數 ​

名稱類別說明範圍 / 種類預設值
unit下拉選項性別男性(male), 女性(female)-

Python ​

python
face_expression = FaceExpression(0)

face_expression.gender_confidence('male')
face_expression.gender_confidence('female')

偵測到表情? ​

是否識別出了表情

expression_detected

參數 ​

(無)

Python ​

python
face_expression = FaceExpression(0)

face_expression.expression_detected()

表情是特定值? ​

回傳識別出的表情是否與指定的值一致,結果為 true(True) / false(False)。

expression_check

參數 ​

名稱類別說明範圍 / 種類預設值
unit下拉選項表情生氣(angry), 厭惡(disgusted), 害怕(fearful), 開心(happy), 無表情(neutral), 悲傷(sad), 驚訝(surprised)-

Python ​

python
face_expression = FaceExpression(0)

face_expression.is_expression('happy')
face_expression.is_expression('sad')

表情的信心度 ​

是所選表情的機率(信心度)

expression_confidence

參數 ​

名稱類別說明範圍 / 種類預設值
unit下拉選項表情angry, disgusted, fearful, happy, neutral, sad, surprised-

Python ​

python
face_expression = FaceExpression(0)

face_expression.expression_confidence('happy')
face_expression.expression_confidence('angry')

臉部表情模型載入狀態 ​

回傳年齡、性別和表情模型的載入狀態。
還沒有載入時回傳 0,正在載入時回傳 1,載入完成時回傳 2。

model_state

參數 ​

(無)

Python ​

python
face_expression = FaceExpression(0)

face_expression.model_state()