GitHub - TencentYouTu/java_sdk: java sdk for TencentYoutuyun-person-face-service
1. 下载sdk到您的目录
git clone https://github.com/TencentYouTu/java_sdk.git
2. 在你的项目里引入本项目dist目录下的json.jar和youtu-java-sdk.jar包或者直接引入源码
3. 导入包并创建Youtu对象,然后调用相应方法
import org.json.JSONObject;
import com.youtu.*;
// 请把下面的APP_ID、SECRET_ID和SECRET_KEY换成你自己的数据,下面的数据已经不可用
public static final String APP_ID = "1000234";
public static final String SECRET_ID = "AKIDUIsdfDlPDt5mZT0GisFcQh1nMOox";
public static final String SECRET_KEY = "ind5yAd55ZspBcjuXi8YU8RL";
//优图初始化方式
Youtu faceYoutu = new Youtu(APP_ID, SECRET_ID, SECRET_KEY,Youtu.API_YOUTU_END_POINT);
//腾讯云初始化方式;2种初始化方式选择一种即可,优图是免费提供给大家使用的
Youtu faceQcloud = new Youtu(APP_ID, SECRET_ID, SECRET_KEY,Youtu.API_TENCENTYUN_END_POINT);
//人脸检测调用示例
JSONObject respose = faceYoutu.DetectFace("test.jpg");
//get respose
System.out.println(respose);
//get detail info
if(respose.getInt("errorcode")==0){
System.out.println(respose.get("image_height"));
System.out.println(respose.get("face"));
System.out.println(respose.getJSONArray("face").getJSONObject(0).get("yaw"));
System.out.println(respose.getInt("errorcode"));
System.out.println(respose.get("errormsg"));
}