face++人脸识别出现错误,索引超范围
源代码:
new Thread(new Runnable() {
public void run() {
try {
File mfile=new File(Environment.getExternalStorageDirectory()+"/test0");
FileInputStream fis=new FileInputStream(mfile);
int length=fis.available();
byte[] buffer=new byte[length];
fis.read(buffer);
fis.close();
HttpRequests httpRequests = new HttpRequests(constant.KEY, constant.SECRET, true, true);
JSONObject result = httpRequests.detectionDetect(new PostParameters().setImg(buffer));
System.out.println(result);
System.out.println(result.getJSONArray("face").getJSONObject(0).getJSONObject("position").getJSONObject("center"));
} catch (FaceppParseException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
}).start();
这是错误:
05-09 20:41:11.086 31909-567/com.example.hayden.facepass W/System.err: org.json.JSONException: Index 0 out of range [0..0)
05-09 20:41:11.086 31909-567/com.example.hayden.facepass W/System.err: at org.json.JSONArray.get(JSONArray.java:282)
05-09 20:41:11.086 31909-567/com.example.hayden.facepass W/System.err: at org.json.JSONArray.getJSONObject(JSONArray.java:510)
05-09 20:41:11.086 31909-567/com.example.hayden.facepass W/System.err: at com.example.hayden.facepass.Userface$1$2.run(Userface.java:103)
05-09 20:41:11.086 31909-567/com.example.hayden.facepass W/System.err: at java.lang.Thread.run(Thread.java:841)
求大神解答,非常感谢。