猴子
狐狸
import com.baidu.aip.imageclassify.AipImageClassify;
import org.json.JSONObject;
import java.util.HashMap;
public class Sample {
//设置APPID/AK/SK
public static final String APP_ID = "25053576";
public static final String API_KEY = "LVy72lb9RiKdixRaG06iUBnz";
public static final String SECRET_KEY = "Mcw9Ad11m4BKCM9lHI776fgmIpnA4fdv";
public static void main(String[] args) {
// 初始化一个AipImageClassify
AipImageClassify client = new AipImageClassify(APP_ID, API_KEY, SECRET_KEY);
// 可选:设置网络连接参数
client.setConnectionTimeoutInMillis(2000);
client.setSocketTimeoutInMillis(60000);
// 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>();
options.put("baike_num", "5");
// 参数为本地路径
/*
String image = "C:\\Users\\杜子轩\\Desktop\\安妮海瑟薇.JPG";
JSONObject res = client.advancedGeneral(image, options);
System.out.println(res.toString(2));*/
//动物识别
String image = "C:\\Users\\杜子轩\\Desktop\\monkey.png";
JSONObject res = client.animalDetect(image, options);
System.out.println(res.toString(2));
}
}