2.2.8. 静止画による顔検知

Windows/Linux/Arm_Linux 用のAPIは、以下の解説をご参照ください。Android 用 APIについては、「Android 用 API の仕様 」をご参照ください。

Android 用APIについては「Android用APIの仕様」をご参照ください。

stid_facepro_detector_create_handle

機能:モデルファイルをロードすることによって、detectorハンドルを作成します。

注意:

  1. 現バージョンSDKのハンドルはマルチスレッドによる呼び出しに対応していないため、1スレッドごとに1つのハンドルを作成する必要があります。

  2. 1つのスレッドは初期化する引数は一度だけ呼び出す必要があります。その後、繰り返しハンドルを作成しなくても顔検知引数を複数回呼び出すことができます。

定義:

STID_SDK_API
stid_result_t
stid_facepro_detector_create_handle(
    stid_handle_t* out_handle,
    const char *alignment_model_filename,
    unsigned int config
);

引数

  • [out] out_handle:初期化されたdetectorハンドルです。利用しない場合は、destroy_handleを呼び出してリソースを解放する必要があります。

  • [in] alignment_model_filename:alignmentのモデルファイルの所在位置をロードします。

  • [in] config:顔認識機の構成項目を設定します。詳細についてはセクションAPIと構造体のパラメーターのマクロ定義 #config(detect)のセクションをご参照ください。

返り値:

  • [return]:正常の場合はSTID_OKが表示、エラーになった場合はエラーコードが表示されます。

stid_facepro_detector_destroy_handle

機能:detectorハンドルを解放します。

定義:

STID_SDK_API
void
stid_facepro_detector_destroy_handle(
    stid_handle_t handle
);

引数:

  • [in] handle:解放するハンドルを入力します。

stid_facepro_detector_detect

機能:1フレームの画像情報を入力すると、顔枠、特徴点情報等が返されます。

定義

STID_SDK_API
stid_result_t
stid_facepro_detector_detect(
    stid_handle_t handle,
    const stid_image_t* input_image,
    stid_orientation_t face_orientation,
    stid_detection_result_t **out_detection_result_array,
    stid_landmarks_t **out_landmarks_array,
    int *out_face_count
);

引数:

  • [in] handle:初期化されたハンドルを表示します。

  • [in] input_image:1フレームの画像をロードしてください。

  • [in] face_orientation:入力した画像中の顔の向きを指定してください。上向きの写真がより効果的に情報を取得できます。

  • [out] out_detection_result_array:検知された顔枠情報のアレイを表示します(顔枠の面積順にリストアップし、アレイの個数はout_face_countで表示された数字となります)。API stid_facepro_release_detection_results_arrayを呼び出してハンドルを解放する必要があります。

  • [out] out_landmarks_array:検知された顔特徴点のアレイを表示します。アレイの要素はout_detection_result_arrayに対応します。APIによるメモリの配分が決められます。API stid_facepro_release_landmarks_arrayを呼び出してハンドルを解放する必要があります。

  • [out] out_face_count:検知された顔の数が表示されます。

返り値:

  • [return]:正常の場合はSTID_OKが表示、エラーになった場合はエラーコードが表示されます。

stid_facepro_set_detector_threshold

機能::顔枠検知のしきい値を設定できます。設定後、stid_facepro_detector_detect APIはstid_detection_result_t構造体で得たスコアの顔枠をフィルタリングし、スコアが設定したしきい値より高い場合のみ、顔枠が戻されます。

定義

STID_SDK_API
stid_result_t
stid_facepro_set_detector_threshold(
    stid_handle_t handle,
    float threshold
);

引数

  • [in] handle:初期化されたハンドルを表示します。

  • [in] threshold:閾値の設定。有効範囲:(0.0、1.0)

返り値:

  • [return]:正常の場合はSTID_OKが表示、エラーになった場合はエラーコードが表示されます。

stid_facepro_release_detection_results_array

機能:detection_resultsアレイを解放できます。

定義

STID_SDK_API
void
stid_facepro_release_detection_results_array(
    const stid_detection_result_t *results_array,
    int results_array_size
);

引数

  • [in] results_array:解放するdetection_resultsアレイのヘッダを入力してください。

  • [in] results_array_size:解放するdetection_resultsアレイの個数を入力してください。

stid_facepro_release_landmarks_array

機能:アレイを解放します。

定義:

STID_SDK_API
void
stid_facepro_release_landmarks_array(
    const stid_landmarks_t *landmarks_array,
    int landmarks_array_count
);

引数:

  • [in] landmarks_array:解放するandmarksアレイのヘッダを入力してください。

  • [in] landmarks_array_count:解放するlandmarksアレイの個数を入力してください。

顔枠

0-32

鼻筋

43-46

左の眉

33-37、64-67

右の眉

38-42、68-71

左まぶた

52-57

右まぶた

58-63

左目の瞳

72-74、104

右目の瞳

75-77、105

鼻の下側

47-51

鼻の外側

78-83

上唇

84-90、96-100

下唇

91-95、101-103

最終更新