0
任何人都可以告诉我哪种方法是Android中onLine FaceDetection的最佳方式。有没有相同的API?如果是的话,那我们该如何实现呢?请为我提供正确的解决方案。Android中的FaceDetection onLine API
在此先感谢。
任何人都可以告诉我哪种方法是Android中onLine FaceDetection的最佳方式。有没有相同的API?如果是的话,那我们该如何实现呢?请为我提供正确的解决方案。Android中的FaceDetection onLine API
在此先感谢。
您可以使用相同的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,如果检测到面部它给劈头盖脸的所有信息如果没有的话doen't给予任何信息。你必须解析该JSON,并得到结果,并享受........
Thanx Sanat,它的工作原理 – 2012-03-01 09:19:30