Giter VIP home page Giter VIP logo

facepp-java-sdk's Introduction

FacePlusPlus Java SDK

note: this branch has outdated, for new api please tray to use facepp-v3 branch.

This SDK uses apache.http lib and json lib.

1. Install

  1. download facepp.jar;
  2. add it to java project.

2. Import package

  • import com.facepp.*;

    or

  • AutoComplete it with your editor or IDE.

3. Call FaceppAPI

  1. create a com.facepp.http.HttpRequests object

    HttpRequests httpRequests = new HttpRequests(you_api_key_string, you_api_secret_string);

  2. create a com.facepp.http.PostParameters object with all parameters

    PostParameters postParameters = new PostParameters().setUrl("http://faceplusplus.com/static/img/demo/8.jpg").setAttribute("all");

  3. request

    httpRequests.request("detection", "detect", postParameters);

    or

    httpRequests.detectionDetect(postParameters);

  4. get the result use the com.facepp.json.FaceppJson object

    FaceppResult result = httpRequests.detectionDetect(postParameters);

4. Get value from result

  • Example:

    result.get("face").getCount()

    result.get("face").get(0).get("face_id").toString()

    result.get("face").get(0).get("attribute").get("gender").get("confidence").toDouble()

5. Debug

  1. View the post request

    postParameters.getMultiPart().writeTo(System.out);

  2. View the result like a pure json

    System.out.println(result)

  • a sample about multipart http post message

      --0soLYaK4lNBytrh912fNS15mSORsgy_J
      Content-Disposition: form-data; name="PERSON_NAME"
      Content-Type: text/plain; charset=US-ASCII
      Content-Transfer-Encoding: 8bit
      
      
      MY_PERSON_NAME
      --0soLYaK4lNBytrh912fNS15mSORsgy_J
      Content-Disposition: form-data; name="GROUP_NAME"
      Content-Type: text/plain; charset=US-ASCII
      Content-Transfer-Encoding: 8bit
      
      
      MY_GROUP_NAME
      --0soLYaK4lNBytrh912fNS15mSORsgy_J--
    

6. For Android

  • note that you can not requst on MainActivity, you need to new a thread to do what you want

  • note that you need add internet uses-permission into AndroidManifest.xml

    <uses-permission android:name="android.permission.INTERNET"/>

7. More sample codes

  • FaceppDemo

    An Java project with FaceppSDK

  • FaceppAndroidDemo

    An Android project with FaceppSDK

  • PictureDetect

    An Android application. To get a picture, detect with FaceppSDK, then mark all faces out.

7. Change Log

  • 1.0.0

    The default api

  • 1.1.0

    Add the new api `grouping' into SDK.

  • 1.2.0

    Add https request method, and set it to default. We can use debug = true to open http to instead of https.

facepp-java-sdk's People

Contributors

moon5ckq avatar jia-kai avatar

Watchers

James Cloos avatar Luis Tiago Andrighetto Hablich avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.