2012-03-01 9 views
0

AndroidでonLine FaceDetectionの最適な方法を教えてください。同じAPIがありますか?はいの場合、それをどのように実装できますか?適切な解決策を提案してください。AndroidのFaceDetection onLine API

ありがとうございます。

答えて

0

Face.com APIを使用することもできます。

顔検出後に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; 

これは顔が検出された場合、それはdoen'tギブ、顔に関するすべての情報を提供しない場合は、JSONとしてレスポンス文字列を返します。任意の情報。 JSONを解析して結果を得て楽しむ必要があります........

+0

Thanx Sanat、それは動作します –