Skip to content

顔検出 ​

インスタンスの宣言 ​

顔検出(FaceDetection) ブロックを作業領域に追加すると、Python コードには次のようなインスタンスの宣言が自動的に挿入されます:

python
face_detection = FaceDetection(0)
# 複数のインスタンスがある場合
face_detection_1 = FaceDetection(1)

パラメーター ​

名前区分説明範囲・種類デフォルト値
indexドロップダウンオプションインスタンス番号(0 から始まる)0 以上の整数0

カメラを設定 ​

顔検出に使うカメラを設定します。

device

パラメーター ​

名前区分説明範囲・種類デフォルト値
unitドロップダウンオプションカメラ機器の名前システムのカメラのラベル-

Python ​

python
face_detection = FaceDetection(0)

face_detection.device('')

顔モデルを読み込む ​

学習済みの顔モデルを読み込みます。「顔検出」モジュールの機能を使うには、この操作が必ず必要です。

load_model

パラメーター ​

名前区分説明範囲・種類デフォルト値
waitチェックボックス読み込みの完了を待つかどうかTRUE / FALSETRUE

Python ​

python
face_detection = FaceDetection(0)

face_detection.load_model(wait=True)

顔を1回検出 ​

いま画面にある顔を見つけて、1 回だけ表示します。

detect_once

パラメーター ​

(なし)

Python ​

python
face_detection = FaceDetection(0)

face_detection.detect_once()

顔の連続検出を開始 / 停止 ​

いま画面にある顔を続けて追いかけながら、画面上に表示します。

detect_continuous

パラメーター ​

名前区分説明範囲・種類デフォルト値
unitドロップダウンオプション動作開始(start), 停止(stop)-

Python ​

python
face_detection = FaceDetection(0)

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

結果を表示 ​

カメラの画面に顔検出の結果を表示するかどうかを決めます。

display

パラメーター ​

名前区分説明範囲・種類デフォルト値
onドロップダウンオプション表示 ON / OFF表示(on=True), 非表示(off=False)TRUE

Python ​

python
face_detection = FaceDetection(0)

face_detection.display(True)
face_detection.display(False)

顔の部位の位置 ​

顔または顔の部位の位置の座標を返します。

face_data

パラメーター ​

名前区分説明範囲・種類デフォルト値
unitドロップダウンオプション顔の部位顔(face), 左目(left eye), 右目(right eye), 左耳(left ear), 右耳(right ear), 鼻(nose), 口(mouth)-
posドロップダウンオプション座標の種類x, y-

Python ​

python
face_detection = FaceDetection(0)

face_detection.face('x')
face_detection.left_eye('y')
face_detection.right_eye('x')
face_detection.left_ear('x')
face_detection.right_ear('y')
face_detection.nose('x')
face_detection.mouth('y')

顔の四角形の情報 ​

顔の領域の四角形の位置/大きさの値を返します。

face_square

パラメーター ​

名前区分説明範囲・種類デフォルト値
posドロップダウンオプション四角形の情報最小x座標(min_x), 最大x座標(max_x), 最小y座標(min_y), 最大y座標(max_y), 幅(width), 高さ(height), 面積(area)-

Python ​

python
face_detection = FaceDetection(0)

face_detection.face('min_x')
face_detection.face('width')
face_detection.face('area')

2つの部位の間の距離 ​

顔の 2 つの部位の間の距離を返します。

distance

パラメーター ​

名前区分説明範囲・種類デフォルト値
unit1ドロップダウンオプション1 つ目の部位face, left_eye, right_eye, left_ear, right_ear, nose, mouth-
unit2ドロップダウンオプション2 つ目の部位face, left_eye, right_eye, left_ear, right_ear, nose, mouth-
typeドロップダウンオプション距離の種類距離(省略または None), 横の距離(horizontal), 縦の距離(vertical)None

Python ​

python
face_detection = FaceDetection(0)

face_detection.get_distance('left_eye', 'right_eye')  # 距離
face_detection.get_distance('left_eye', 'right_eye', 'horizontal')  # 横の距離
face_detection.get_distance('nose', 'mouth', 'vertical')  # 縦の距離

顔モデルの読み込み状態 ​

顔モデルの読み込み状態を返します。
まだ読み込んでいなければ 0、読み込み中なら 1、読み込みが完了していれば 2 を返します。

model_state

パラメーター ​

(なし)

Python ​

python
face_detection = FaceDetection(0)

face_detection.model_state()

顔を検出した? ​

顔を見つけたかどうか

detected

パラメーター ​

(なし)

Python ​

python
face_detection = FaceDetection(0)

face_detection.detected()