Android中的人脸检测在线API
有谁能告诉我,在安卓系统中,哪一种是在线人脸检测的最佳方式。有相同的API吗?如果是,那么我们如何实施?请给我建议正确的解决方案Android中的人脸检测在线API,android,Android,有谁能告诉我,在安卓系统中,哪一种是在线人脸检测的最佳方式。有相同的API吗?如果是,那么我们如何实施?请给我建议正确的解决方案 提前感谢。您也可以使用Face.com API 它在facedetection之后返回JSON响应。 首先,您必须在Face.com上注册,它将生成您的API ID和密钥。 然后,您必须在face.com服务器上上传图像,如下所示: Bitmap img = BitmapFactory.decodeFile(paramFile.getPath());
提前感谢。您也可以使用Face.com API 它在facedetection之后返回JSON响应。 首先,您必须在Face.com上注册,它将生成您的API ID和密钥。 然后,您必须在face.com服务器上上传图像,如下所示:
Bitmap img = BitmapFactory.decodeFile(paramFile.getPath());
System.out.println("The Width="+img.getWidth()+" & Height:"+img.getHeight());
String str = "";
if (this.httpclient == null)
{
BasicHttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, 10000);
HttpConnectionParams.setSoTimeout(httpParams, 10000);
this.httpclient = new DefaultHttpClient(httpParams);
}
this.httpclient.getParams().setParameter("http.protocol.version", HttpVersion.HTTP_1_1);
HttpPost post = new HttpPost("http://api.face.com/faces/detect.json");
HttpClientParams.setCookiePolicy(post.getParams(), "compatibility");
MultipartEntity multiPart = new MultipartEntity();
multiPart.addPart("upload", new FileBody(paramFile, "image/jpeg"));
multiPart.addPart("api_key", new StringBody("5438f02c1f03bbd229e209abfc811cfb"));
multiPart.addPart("api_secret", new StringBody("6892f15e9721ad0e720a82f8a7d214c9"));
multiPart.addPart("f_upload", new StringBody(paramFile.getName()));
multiPart.addPart("detector", new StringBody("Aggressive"));
multiPart.addPart("attributes", new StringBody("all"));
post.setEntity(multiPart);
response = this.httpclient.execute(post);
HttpEntity responseEntity = response.getEntity();
if (responseEntity != null)
str = EntityUtils.toString(responseEntity);
return (String)str;
这将返回一个作为JSON的响应字符串,如果检测到该面,它将提供有关该面的所有信息,如果没有,则不提供任何信息。您必须解析JSON并获得结果,然后享受