http://ip:port/identity/multiface_image_omni_verification/stateless
first_image_file に相当する図 A に 2 つの顔 (a1、a2) が含まれていて、second_image_file に相当する 図 B にも 2 つの顔 (b1、b2) が含まれているとします。a1b1 などの値は、図 A に含まれる顔 a1 と図 B に含まれる顔 b1 の比較スコアを表します。
{
'code: Int, # システムレスポンスコード
'scores': array, # [[a1b1 顔比較スコア, a1b2 顔比較スコア], [a2b1 顔比較スコア, a2b2 顔比較スコア]]
"face_rects":{ hash,# 各画像の顔枠
'first_image_face_rects':[a1 顔枠の座標], [a2 顔枠の座標]],
'second_image_face_rects,:[[b1 顔枠の座標],[b2 顔枠の座標]]
},
'request_id': string # このリクエストのID
}
{
'request_id': string,
'code': int,
'message': string
}
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
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();
}
}