1.2 /identity/multiface_image_omni_verification/stateless

比較対象の顔写真に複数の顔が含まれる場合、2つの写真に含まれる顔の各グループの類似度スコアを返します。

写真の規格は、運用マニュアル3章 写真と動画の規格をご参照ください。

リクエストモード

POST

リクエスト URL

http://ip:port/identity/multiface_image_omni_verification/stateless

リクエストパラメーター

フィールド

必須

説明

first_encrypted_image

string

Yes

暗号化された写真1。暗号化方法の参照: 個人データの暗号化

second_encrypted_image

string

Yes

暗号化された写真2。暗号化方法の参照: 個人データの暗号化

auto_rotate

boolean

No

デフォルト値はfalseで、写真が回転していないことを示します。値がtrueの場合、写真は自動的に回転されます

通常のレスポンス

フィールド

説明

code

int

システムレスポンスコード:1000

scores

array

写真の各グループの顔のスコアの比較。推奨しきい値:0.7〜0.8

face_rects

hash

各写真の顔の顔枠

request_id

string

このリクエストのID

例:

first_image_file に相当する図Aに2つの顔(a1、a2)が含まれていて、second_image_file に相当する図Bにも2つの顔(b1、b2)が含まれているとします。a1b1などの値は、図Aに含まれる顔a1と図Bに含まれる顔b1の比較スコアを表します。

{
    "code": 1000,
    "scores": [ # [[a1b1 顔比較スコア, a1b2 顔比較スコア], [a2b1 顔比較スコア, a2b2 顔比較スコア]]
  "face_rects":{ hash,# 各写真の顔枠
        [
            float,
            float,
            float,
            float
        ]
    ],
    "face_rects": { # face frame in each image
        "first_image_face_rects": [ # [[a1 顔枠の座標], [a2 顔枠の座標]]
            [
                int,
                int,
                int,
                int
            ],
            [
                int,
                int,
                int,
                int
            ]
        ],
        "second_image_face_rects": [ # [[b1 顔枠の座標],[b2 顔枠の座標]]
            [
                int,
                int,
                int,
                int
            ],
            [
                int,
                int,
                int,
                int
            ]
        ]
    },
    "request_id": "2c4156bb47794f66a2ed50d5a87e5ca2"
}

顔比較スコアのしきい値とエラー率との対応関係

閾値

0.4

0.5

0.6

0.7

0.8

0.9

エラー率

1/10

1/100

1/1000

1/10,000

1/100,000

1/1,000,000

推奨しきい値:0.7以上

異常なレスポンス

フィールド

説明

code

int

システムレスポンスコード

message

string

エラーメッセージ

request_id

string

リクエストのID

{
    "code": int,
    "message": string,
    "request_id": string
}

システムレスポンスコードの説明

コード

フィールドの値

説明

1200

invalid argument

無効な入力パラメーター

2003

invalid image size

写真サイズ(幅と高さのピクセル数)が要件を満たしていません

2004

invalid content length

写真のファイルサイズが要件を満たしていません

2005

invalid image type or corrupted

写真タイプが要件を満たしていません

4000

detection failed

特徴の抽出に失敗しました。写真に顔が検出されませんでした

可能なHTTPステータスコード

ステータスコード

ステータスフィールド

400

BAD_REQUEST

404

NOT_FOUND

411

LENGTH_REQUIRED

413

PAYLOAD_TOO_LARGE

500

INTERNAL_ERROR

使用サンプル

Curl

curl -X POST "http://ip:port/identity/multiface_image_omni_verification/stateless" \
  -d first_encrypted_image=xxx \
  -d second_encrypted_image=xxx \
  -d auto_rotate=true

Java

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class HttpClient {
    public static final String POST_URL = "http://127.0.0.1:3000/identity/multiface_image_omni_verification/stateless";
    private static AESCipher cipher = new AESCipher("dcbbad6765e14139a07d34b92292a672", "df25d188a061");

    public static void Post() throws Exception {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpPost post = new HttpPost(POST_URL);

        List<NameValuePair> params = new ArrayList<>();

        String firstEncryptedImage = cipher.encrypt(
                Files.readAllBytes(Paths.get("src/main/resources/face_01.jpg")));
        String secondEncryptedImage = cipher.encrypt(
                Files.readAllBytes(Paths.get("src/main/resources/face_02.jpg")));

        params.add(new BasicNameValuePair("first_encrypted_image", firstEncryptedImage));
        params.add(new BasicNameValuePair("second_encrypted_image", secondEncryptedImage));

        post.setEntity(new UrlEncodedFormEntity(params));
        HttpResponse response = httpclient.execute(post);

        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity respEntity = response.getEntity();
            BufferedReader reader = new BufferedReader(new InputStreamReader(respEntity.getContent()));
            String line = reader.readLine();
            System.out.println(line);
        } else {
            HttpEntity respEntity = response.getEntity();
            String responseString = EntityUtils.toString(respEntity);
            System.out.println("error:" + response.getStatusLine().getStatusCode()
                    + "  " + response.getStatusLine().getReasonPhrase());
            System.out.println("cause of error:" +responseString);
        }
    }

    public static void main(String[] args) throws Exception {
        Post();
    }
}

最終更新