第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Face++ 比較 API

Face++ 比較 API

桃花長相依 2023-08-16 18:06:50
我需要比較java中的兩張人臉圖像及其置信度值。我正在嘗試學(xué)習閱讀face++提供的官方文檔,但我認為它有點差。我需要在這里使用面部比較API: https: //console.faceplusplus.com/documents/5679308。我不明白如何構(gòu)建發(fā)送請求的網(wǎng)址。頁面末尾有這樣一段代碼:curl -X POST "https://api-us.faceplusplus.com/facepp/v3/compare" \ -F "api_key=<api_key>" \ -F "api_secret=<api_secret>" \ -F "face_token1=c2fc0ad7c8da3af5a34b9c70ff764da0" \ -F "face_token2=ad248a809408b6320485ab4de13fe6a9"現(xiàn)在,我在他們的文檔中看到的唯一代碼是:https://console.faceplusplus.com/documents/7078069但這不起作用,或者至少,這不是為了“面部比較”。我需要創(chuàng)建并獲取面部比較 API 的請求(開頭的第一個鏈接)。我找不到任何有關(guān)如何執(zhí)行此操作的 java 示例。我是用java做的
查看完整描述

1 回答

?
慕田峪4524236

TA貢獻1875條經(jīng)驗 獲得超5個贊

使用文檔中提供的相同示例代碼,您所需要做的就是更改 main 方法,如下所示:

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


? ? // Create a new file object for the first file and get bytes from file

? ? File file = new File("C:\\Users\\ihene\\Desktop\\my-photo.jpg");

? ? byte[] buff1 = getBytesFromFile(file);


? ? // Create a new file object for the second file and get bytes from file

? ? File file2 = new File("C:\\Users\\ihene\\Desktop\\esan-caleb.jpg");

? ? byte[] buff2 = getBytesFromFile(file2);


? ? // Data needed to use the Face++ Compare API

? ? String url = "https://api-us.faceplusplus.com/facepp/v3/compare";

? ? HashMap<String, String> map = new HashMap<>();

? ? HashMap<String, byte[]> byteMap = new HashMap<>();

? ? map.put("api_key", "dam4ZdTkSsZOUAiR4oQpP3DRnjEz1fcD");

? ? map.put("api_secret", "0MOCfpum1Lec06EMOzuJPOEa_EhM4Ttg");


? ? byteMap.put("image_file1", buff1);

? ? byteMap.put("image_file2", buff2);


? ? try {

? ? ? ? // Connecting and retrieving the JSON results

? ? ? ? byte[] bacd = post(url, map, byteMap);

? ? ? ? String jsonStr = new String(bacd);


? ? ? ? // Parse the JSON and get the confidence value

? ? ? ? JSONObject obj = new JSONObject(jsonStr);

? ? ? ? double confidence = obj.getDouble("confidence");

? ? ? ? System.out.println(confidence);

? ? } catch (Exception e) {

? ? ? ? e.printStackTrace();

? ? }

}

只需將PATH_TO_FILE_1、PATH_TO_FILE_2、YOUR_API_KEY、 和替換YOUR_API_SECRET為適當?shù)闹导纯?。它?yīng)該有效。


我使用兩張臉部屬于同一個人的圖像和另外兩張不同臉部的圖像測試了 API。這是我得到的前者的輸出:


{"faces1": [{"face_rectangle": {"width": 156, "top": 210, "left": 142, "height": 156}, "face_token": "1ee9de6d362b0c8c1bf240a70fbf3eac"}], "faces2": [{"face_rectangle": {"width": 156, "top": 210, "left": 142, "height": 156}, "face_token": "0a7c539f3603aa744ee18c65acc224a8"}], "time_used": 531, "thresholds": {"1e-3": 62.327, "1e-5": 73.975, "1e-4": 69.101}, "confidence": 97.389, "image_id2": "Fc64vrBtETVmP2cS+BoW/Q==", "image_id1": "Fc64vrBtETVmP2cS+BoW/Q==", "request_id": "1569184566,0cc04f1a-1495-4316-928c-1efe7d6836dc"}

請注意,這里的置信度是97.389。文件稱,“置信度越高,表明兩張臉屬于同一個人的可能性就越高。” 所以,這符合我們的預(yù)期。對于后面具有不同面孔的圖像,輸出如下:


{"faces1": [{"face_rectangle": {"width": 156, "top": 210, "left": 142, "height": 156}, "face_token": "c7d8561f0235a99d9b060750c7a9c3c7"}], "faces2": [{"face_rectangle": {"width": 75, "top": 44, "left": 53, "height": 75}, "face_token": "ad87092cb593128c015c2e2221b962f2"}], "time_used": 533, "thresholds": {"1e-3": 62.327, "1e-5": 73.975, "1e-4": 69.101}, "confidence": 53.993, "image_id2": "MiZOf00hrq7OmAxc3+n7sg==", "image_id1": "Fc64vrBtETVmP2cS+BoW/Q==", "request_id": "1569185082,0bfd0a0f-a376-4dac-92bd-924c34ef76ed"}

此處,置信度為53.933。


查看完整回答
反對 回復(fù) 2023-08-16
  • 1 回答
  • 0 關(guān)注
  • 153 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號