note: this branch has outdated, for new api please tray to use facepp-v3 branch.
This SDK uses apache.http lib and json lib.
- download facepp.jar;
- add it to java project.
-
import com.facepp.*;
or
-
AutoComplete it with your editor or IDE.
-
create a com.facepp.http.HttpRequests object
HttpRequests httpRequests = new HttpRequests(you_api_key_string, you_api_secret_string);
-
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");
-
request
httpRequests.request("detection", "detect", postParameters);
or
httpRequests.detectionDetect(postParameters);
-
get the result use the com.facepp.json.FaceppJson object
FaceppResult result = httpRequests.detectionDetect(postParameters);
-
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()
-
View the post request
postParameters.getMultiPart().writeTo(System.out);
-
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--
-
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"/>
-
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.
-
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.