资源说明:public class Recognize {
public static final String APPKEY = "your_appkey_here";// 你的appkey
public static final String URL = "http://api.jisuapi.com/licenseplaterecognition/recognize";
public static final String pic = "11.jpg";// 图片地址
public static void Get() {
String result = null;
String url = URL + "?appkey=" + APPKEY;
Map param = new HashMap();
try {
param.put("pic", getBase64(pic));
result = HttpUtil.sendPost(url, param, "UTF-8");
JSONObject json = JSONObject.fromObject(result);
if (json.getInt("status") != 0) {
System.out.println(json.getString("msg"));
} else {
JSONObject resultarr = (JSONObject) json.opt("result");
Iterator itt = resultarr.keys();
while (itt.hasNext()) {
String key = itt.next().toString();
String value = resultarr.getString(key);
System.out.println(key + ":" + value);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 图片转为Base64编码格式
*
* @param imgFile
* @return
*/
public static String getBase64(String imgFile) {
InputStream inputStream = null;
byte[] data = null;
try {
inputStream = new FileInputStream(imgFile);
data = new byte[inputStream.available()];
inputStream.read(data);
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
// 加密
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);
}
}
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。