6.1.3. /identity/liveness_image_verification/stateless

インターフェースを介してアップロードされた顔画像と生体認証データを比較して、画像内の顔が同一人物のものであるかどうかを判断します。

画像は、以下の要件を満たすものとします。

  1. JPG (JPEG)、BMP、PNG、GIF、TIFF のいずれかの形式

  2. 幅と高さは 8 px 以上 5,000 px 以下

  3. ファイルサイズは 5 MB 以下

リクエストモード

POST

リクエスト URL

http://ip:port/identity/liveness_image_verification/stateless

リクエストパラメーター

通常のレスポンス

{
  'request_id': 'xxx',
  'code': xxx,
  'verification_score': xxx
}

顔比較スコアの閾値とエラー率との対応関係:

推奨閾値: 0.7 以上

異常なレスポンス

{
  'request_id': 'xxx',
  'code': xxx,
  'message': xxx
}

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

可能性のある http ステータスコード:

使用サンプル

curl サンプル

curl -X POST "http://ip:port/identity/liveness_image_verification/stateless" \
  -F liveness_file=@/PATH/TO/FILE \
  -d encrypted_image=xxx \
  -d auto_rotate=true

Java サンプル

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class HttpClient {
    public static final String POST_URL = "http://127.0.0.1:3000/identity/liveness_image_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);

        MultipartEntityBuilder entity = MultipartEntityBuilder.create();
        String encryptedImage = cipher.encrypt(
                Files.readAllBytes(Paths.get("src/main/resources/face_01.jpg")));

        entity.addPart("liveness_file", new FileBody(new File("src/main/resources/mobile.protobuf")));
        entity.addPart("encrypted_image", new StringBody(encryptedImage));
        entity.addPart("auto_rotate", new StringBody("true"));

        post.setEntity(entity.build());
        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();
    }
}

最終更新