6.3.1. /liveness/silent_detection/stateless
サイレント生体検知のインターフェースです。
リクエストモード
POST
リクエスト URL
http://ip:port/liveness/silent_detection/stateless
リクエストパラメーター
フィールド
型
必須
説明
return_image
boolean
No
選出されたフレーム画像と選出されたフレーム画像のタイムスタンプを返すかどうか。 デフォルト値は false で、値が true かつ生体認証が通過した場合に image_timestamp
, base64_image
フィールドが返されます
return_face_image
boolean
No
選出されたフレーム画像の顔のクロップを返すかどうか。 デフォルト値は false で、値が true かつ生体認証が通過した場合に base64_face_image
フィールドは返されます
return_status
boolean
No
エラーステータスの説明を返すかどうかを指定します。デフォルトはfalseで、値がtrueの場合にのみliveness_status
フィールドは返されます
一般的なビデオフォーマットはサポートされています。例えば: .mp4, .avi, .flv, .wmv, .mov, .rm
通常のレスポンス
フィールド
型
説明
request_id
string
リクエストのID
code
int
システムレスポンスコード: 1000
passed
boolean
生体認証に通過したかどうか
liveness_score
float
サイレント生体認証のスコア(参考までに、結果はpassedフィールドを使用してください)
liveness_status
string
サイレントライブネス検出のエラー状態を記述します。このフィールドは、return_status=true の時に返されます
image_timestamp
float
選出されたフレームのタイムスタンプを秒単位で表し、passed=true、return_image=trueの場合に返されます
base64_image
string
選出されたフレーム画像、passed=true、return_image=trueの場合は該当フィールドを返します
base64_face_image
string
選出された顔写真の切り抜き、passed=true、return_face_image=trueの場合に返されます
ここで、liveness_status
の結果は以下のようになる:
ステータス
説明
ok
サイレント生体認証は合格した: 動画の中の人は実在する
hack
サイレント生体認証は合格してない、理由: 捏造した顔 (例えば, ビデオで撮影された顔)
short_time
サイレント生体認証は合格してない、理由: ビデオの持続時間は2s未満
no_face_detected
サイレント生体認証は合格してない、理由: 映像から顔は検出されません
loss_tracking
サイレント生体認証は合格してない、理由: 途中で顔がフレームアウト
face_changed
サイレント生体認証は合格してない、理由: 動画の途中で顔が入れ替わっていました
face_occlusion
サイレント生体認証は合格してない、理由: 一定期間顔が見えなくなる
{
"request_id": string,
"code": int,
"passed": boolean,
"liveness_score": float,
"liveness_status": string,
"image_timestamp": float,
"base64_image": string,
"base64_face_image": string,
}
異常なレスポンス
フィールド
型
説明
request_id
string
リクエストのID
code
int
システムレスポンスコード
message
string
エラーメッセージ
{
'request_id': 'xxx',
'code': xxx,
'message': xxx
}
システムレスポンスコードの説明
コード
フィールドの値
説明
1200
invalid argument
無効な入力パラメーター
2008
invalid video error
無効な動画
4007
liveness silent check 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/liveness/silent_detection/stateless" \
-d encrypted_video=xxx \
-d return_status=true \
-d return_image=true \
-d return_face_image=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/liveness/silent_detection/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 encryptedVideo = cipher.encrypt(
Files.readAllBytes(Paths.get("src/main/resources/video_01.mp4")));
params.add(new BasicNameValuePair("encrypted_video", encryptedVideo));
params.add(new BasicNameValuePair("return_image", "true"));
params.add(new BasicNameValuePair("return_face_image", "true"));
params.add(new BasicNameValuePair("return_status", "true"));
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();
}
}
Last updated
Was this helpful?