Face++ Java 简单实例

Face++ 官网 http://www.faceplusplus.com.cn/

11.jpg

import java.nio.charset.Charset;
import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import com.facepp.error.FaceppParseException;
import com.facepp.http.HttpRequests;
import com.facepp.http.PostParameters;

/*
 * 先识别了一张照片,得出3个人脸,然后创建了3个Person,把这些人脸加入到对应的Person中,再把这些Person加入一个Group中。
 * 通过调用train和recognition来演示人脸识别API。最后删除了创建的Person
 */
public class Test {

    public static void main(String[] args) {

        //初始化函数HttpRequests,传入四个参数依次是API_Key,API_Secret,是否使用CN服务器,是否使用HTTP模式连接。

        //replace api_key and api_secret here (note)
        HttpRequests httpRequests = new HttpRequests("your APIkey", "your API Secret", true, true);

        JSONObject result = null;

        try {

            System.out.println(Charset.forName("UTF-8").name());

            System.out.println("FacePlusPlus API Test:");

            //detection/detect
            //识别图片
            result = httpRequests.detectionDetect(new PostParameters().setUrl("http://cn.faceplusplus.com/wp-content/themes/faceplusplus/assets/img/demo/11.jpg"));
            System.out.println(result);

            System.out.println(result.getJSONArray("face").getJSONObject(0).getJSONObject("position").getJSONObject("center"));

            //创建Person,通过personAddFace添加人脸,通过setPersonName添加中文姓名,最后通过personGetInfo得到每一个Person的信息输出。
            //-----------------Person-----------------
            //person/create
            System.out.println("\nperson/create");
            for (int i = 0; i < result.getJSONArray("face").length(); ++i)
                System.out.println(httpRequests.personCreate(new PostParameters().setPersonName("person_n"+i)));

            new PostParameters().setPersonName("person_n"+0).setFaceId(
                    result.getJSONArray("face").getJSONObject(0).getString("face_id")).getMultiPart().writeTo(System.out);

            //person/add_face
            System.out.println("\nperson/add_face");
            for (int i = 0; i < result.getJSONArray("face").length(); ++i)
                System.out.println(httpRequests.personAddFace(new PostParameters().setPersonName("person_n"+i).setFaceId(
                        result.getJSONArray("face").getJSONObject(i).getString("face_id"))));

            //person/set_info
            System.out.println("\nperson/set_info");
            for (int i = 0; i < result.getJSONArray("face").length(); ++i) {
                new PostParameters().setPersonName("person_n"+i).setTag("china tag_"+i).getMultiPart().writeTo(System.out);
                System.out.println(httpRequests.personSetInfo(new PostParameters().setPersonName("person_n"+i).setTag("china tag_"+i)));
            }

            //person/get_info
            System.out.println("\nperson/get_info");
            for (int i = 0; i < result.getJSONArray("face").length(); ++i)
                System.out.println(httpRequests.personGetInfo(new PostParameters().setPersonName("person_n"+i)));

            //创建Faceset,此处和创建Person基本一致。
            //-----------------Faceset-----------------
            //faceset/create
            System.out.println("\nfaceset/create");
            for (int i = 0; i < result.getJSONArray("face").length(); ++i)
                System.out.println(httpRequests.facesetCreate(new PostParameters().setFacesetName("faceset_n"+i)));

            //faceset/add_face
            System.out.println("\nfaceset/add_face");
            for (int i = 0; i < result.getJSONArray("face").length(); ++i)
                System.out.println(httpRequests.facesetAddFace(new PostParameters().setFacesetName("faceset_n"+i).setFaceId(
                        result.getJSONArray("face").getJSONObject(i).getString("face_id"))));

            //faceset/set_info
            System.out.println("\nfaceset/set_info");
            for (int i = 0; i < result.getJSONArray("face").length(); ++i) {
                new PostParameters().setFacesetName("faceset_n"+i).setTag("china tag_"+i).getMultiPart().writeTo(System.out);
                System.out.println(httpRequests.facesetSetInfo(new PostParameters().setFacesetName("faceset_n"+i).setTag("china tag_"+i)));
            }

            //faceset/get_info
            System.out.println("\nfaceset/get_info");
            for (int i = 0; i < result.getJSONArray("face").length(); ++i)
                System.out.println(httpRequests.facesetGetInfo(new PostParameters().setFacesetName("faceset_n"+i)));

            //创建一个Group,把所有Person加入到Group中去。
            //-----------------Group-----------------
            //group/create
            System.out.println("\ngroup/create");
            System.out.println(httpRequests.groupCreate(new PostParameters().setGroupName("group0")));

            //group/add_person
            System.out.println("\ngroup/add_person");
            ArrayList<String> personList = new ArrayList<String>();
            for (int i = 0; i < result.getJSONArray("face").length(); ++i)
                personList.add("person_n"+i);

            new PostParameters().setGroupName("group0").setPersonName(personList).getMultiPart().writeTo(System.out);
            System.out.println(httpRequests.groupAddPerson(new PostParameters().setGroupName("group0").setPersonName(personList)));

            //group/set_info
            System.out.println("\ngroup/set_info");
            System.out.println(httpRequests.groupSetInfo(new PostParameters().setGroupName("group0").setTag("group tag")));

            //group/get_info
            System.out.println("\ngroup/get_info");
            System.out.println(httpRequests.groupGetInfo(new PostParameters().setGroupName("group0")));

            //通过trainIdentify建立人脸标识模型,再通过trainVerify建立人脸验证模型。
            //-----------------Recognition-----------------

            //recognition/train
            JSONObject syncRet = null; 

            System.out.println("\ntrain/Identify");
            syncRet = httpRequests.trainIdentify(new PostParameters().setGroupName("group0"));
            System.out.println(syncRet);
            System.out.println(httpRequests.getSessionSync(syncRet.getString("session_id")));

            System.out.println("\ntrain/verify");
            for (int i = 0; i < result.getJSONArray("face").length(); ++i) {
                syncRet = httpRequests.trainVerify(new PostParameters().setPersonName("person_n" + i));
                System.out.println(httpRequests.getSessionSync(syncRet.get("session_id").toString()));
            }

            //recognition/recognize
            System.out.println("\nrecognition/identify");
            System.out.println(httpRequests.recognitionIdentify(
                    new PostParameters().setGroupName("group0").setUrl("http://cn.faceplusplus.com/wp-content/themes/faceplusplus/assets/img/demo/5.jpg")));

            //recognition/verify
            System.out.println("\nrecognition/verify");
            System.out.println(
                    httpRequests.recognitionVerify(new PostParameters().setPersonName("person_n0").setFaceId(
                            result.getJSONArray("face").getJSONObject(0).getString("face_id"))));
            System.out.println(
                    httpRequests.recognitionVerify(new PostParameters().setPersonName("person_n1").setFaceId(
                            result.getJSONArray("face").getJSONObject(0).getString("face_id"))));

            //-----------------Info-----------------
            //info/get_app
            System.out.println("\ninfo/get_app");
            System.out.println(httpRequests.infoGetApp());

            //info/get_face
            System.out.println("\ninfo/get_app");
            System.out.println(httpRequests.infoGetFace(new PostParameters().setFaceId(
                    result.getJSONArray("face").getJSONObject(0).getString("face_id"))));

            //info/get_group_list
            System.out.println("\ninfo/get_group_list");
            System.out.println(httpRequests.infoGetGroupList());

            //info/get_image
            System.out.println("\ninfo/get_image");
            System.out.println(httpRequests.infoGetImage(new PostParameters().setImgId(
                    result.getString("img_id"))));

            //info/get_person_nlist
            System.out.println("\ninfo/get_person_nlist");
            System.out.println(httpRequests.infoGetPersonList());

            //info/get_quota
            System.out.println("\ninfo/get_quota");
            System.out.println(httpRequests.infoGetQuota());

            //info/get_session
            System.out.println("\ninfo/get_session");
            System.out.println(httpRequests.infoGetSession(new PostParameters().setSessionId(
                    result.getString("session_id"))));

            //-----At last----
            //person/remove_face
            System.out.println("\nperson/remove_face");
            System.out.println(httpRequests.personRemoveFace(
                    new PostParameters().setPersonName("person_n0").setFaceId(
                            result.getJSONArray("face").getJSONObject(0).getString("face_id"))));

            //group/delete
            System.out.println("\ngroup/delete");
            System.out.println(httpRequests.groupDelete(new PostParameters().setGroupName("group0")));

            //person/delete
            System.out.println("\nperson/delete");
            System.out.println(httpRequests.personDelete(new PostParameters().setPersonName("person_n0")));

            //faceset/delete
            System.out.println("\nfaceset/delete");
            System.out.println(httpRequests.facesetDelete(new PostParameters().setFacesetName("faceset_n0")));

        } catch(FaceppParseException e) {
            e.printStackTrace();
        } catch (Exception e) {
        } finally {
            try {
                for (int i = 1; i < result.getJSONArray("face").length(); ++i) {
                    httpRequests.personDelete(new PostParameters().setPersonName("person_n"+i));
                    httpRequests.facesetDelete(new PostParameters().setFacesetName("faceset_n"+i));
                }
            } catch (JSONException e) {
                e.printStackTrace();
            } catch (FaceppParseException e) {
                e.printStackTrace();
            }
        }
    }
}

结果输出:

UTF-8
FacePlusPlus API Test:
{"face":[{"position":{"mouth_right":{"y":38.653894,"x":80.023902},"mouth_left":{"y":39.814953,"x":71.609512},"center":{"y":33.800623,"x":75.243902},"height":20.872274,"width":16.341463,"nose":{"y":34.450156,"x":74.298293},"eye_left":{"y":30.187726,"x":70.736585},"eye_right":{"y":28.659252,"x":78.349268}},"tag":"","face_id":"beb41e45943f1ca51cfeaf9d5e17807e","attribute":{"age":{"range":10,"value":40},"gender":{"value":"Female","confidence":99.9985},"race":{"value":"White","confidence":58.3153},"smiling":{"value":98.7239}}},{"position":{"mouth_right":{"y":51.956386,"x":25.697317},"mouth_left":{"y":53.221807,"x":17.340268},"center":{"y":47.352025,"x":21.707317},"height":20.560748,"width":16.097561,"nose":{"y":48.353271,"x":22.029073},"eye_left":{"y":43.312773,"x":17.307927},"eye_right":{"y":42.598442,"x":25.091707}},"tag":"","face_id":"f04841f32fecef9846be4970c58e72c1","attribute":{"age":{"range":5,"value":33},"gender":{"value":"Female","confidence":99.9999},"race":{"value":"White","confidence":97.3218},"smiling":{"value":99.5768}}},{"position":{"mouth_right":{"y":35.692212,"x":50.440244},"mouth_left":{"y":37.578193,"x":44.245854},"center":{"y":31.775701,"x":46.585366},"height":18.691589,"width":14.634146,"nose":{"y":32.875078,"x":46.454878},"eye_left":{"y":28.394268,"x":42.39439},"eye_right":{"y":26.697383,"x":49.860976}},"tag":"","face_id":"4d51486ae5d9777bc229f429c1ebf3bb","attribute":{"age":{"range":8,"value":16},"gender":{"value":"Female","confidence":99.9936},"race":{"value":"White","confidence":99.0117},"smiling":{"value":51.1197}}}],"session_id":"d53921e468bb483a8d40cf2898a992ef","img_id":"8b54680a72bc8da8c6550e4ca84a833a","response_code":200,"img_height":321,"img_width":410,"url":"http://cn.faceplusplus.com/wp-content/themes/faceplusplus/assets/img/demo/11.jpg"}
{"y":33.800623,"x":75.243902}

person/create
{"person_id":"154c612b9e1cfaad936c92eefbe24f09","person_name":"person_n0","added_group":0,"tag":"","response_code":200,"added_face":0}
{"person_id":"47f550e53f93e9178597c5868499e269","person_name":"person_n1","added_group":0,"tag":"","response_code":200,"added_face":0}
{"person_id":"f00bc296dc526ffc27ee8a4e2fe634a1","person_name":"person_n2","added_group":0,"tag":"","response_code":200,"added_face":0}
--eUDt49CYA7rdPCgmEYBS9F6rxYEH3xgn
Content-Disposition: form-data; name="person_name"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

person_n0
--eUDt49CYA7rdPCgmEYBS9F6rxYEH3xgn
Content-Disposition: form-data; name="face_id"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

beb41e45943f1ca51cfeaf9d5e17807e
--eUDt49CYA7rdPCgmEYBS9F6rxYEH3xgn--

person/add_face
{"added":1,"response_code":200,"success":true}
{"added":1,"response_code":200,"success":true}
{"added":1,"response_code":200,"success":true}

person/set_info
--JppPoWbcgMZymwV_tLa9D0vYvdtamF85
Content-Disposition: form-data; name="person_name"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

person_n0
--JppPoWbcgMZymwV_tLa9D0vYvdtamF85
Content-Disposition: form-data; name="tag"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

china tag_0
--JppPoWbcgMZymwV_tLa9D0vYvdtamF85--
{"person_id":"154c612b9e1cfaad936c92eefbe24f09","person_name":"person_n0","tag":"china tag_0","response_code":200}
--sv4kQ20H2Vb0oumUGHmu9YBb5k4HnzdT
Content-Disposition: form-data; name="person_name"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

person_n1
--sv4kQ20H2Vb0oumUGHmu9YBb5k4HnzdT
Content-Disposition: form-data; name="tag"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

china tag_1
--sv4kQ20H2Vb0oumUGHmu9YBb5k4HnzdT--
{"person_id":"47f550e53f93e9178597c5868499e269","person_name":"person_n1","tag":"china tag_1","response_code":200}
--Tq_SmfTObMiBwzdZUh5R4RDqzEjwQZVF
Content-Disposition: form-data; name="person_name"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

person_n2
--Tq_SmfTObMiBwzdZUh5R4RDqzEjwQZVF
Content-Disposition: form-data; name="tag"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

china tag_2
--Tq_SmfTObMiBwzdZUh5R4RDqzEjwQZVF--
{"person_id":"f00bc296dc526ffc27ee8a4e2fe634a1","person_name":"person_n2","tag":"china tag_2","response_code":200}

person/get_info
{"face":[{"tag":"","face_id":"beb41e45943f1ca51cfeaf9d5e17807e"}],"person_id":"154c612b9e1cfaad936c92eefbe24f09","person_name":"person_n0","tag":"china tag_0","response_code":200,"group":[]}
{"face":[{"tag":"","face_id":"f04841f32fecef9846be4970c58e72c1"}],"person_id":"47f550e53f93e9178597c5868499e269","person_name":"person_n1","tag":"china tag_1","response_code":200,"group":[]}
{"face":[{"tag":"","face_id":"4d51486ae5d9777bc229f429c1ebf3bb"}],"person_id":"f00bc296dc526ffc27ee8a4e2fe634a1","person_name":"person_n2","tag":"china tag_2","response_code":200,"group":[]}

faceset/create
{"tag":"","faceset_id":"5a9afe6e37572a61da037a087a5f3af0","response_code":200,"added_face":0,"faceset_name":"faceset_n0"}
{"tag":"","faceset_id":"baa1033fb49170da94458c179cd38588","response_code":200,"added_face":0,"faceset_name":"faceset_n1"}
{"tag":"","faceset_id":"99311637228fdb3813e38dbed7950d18","response_code":200,"added_face":0,"faceset_name":"faceset_n2"}

faceset/add_face
{"added":1,"response_code":200,"success":true}
{"added":1,"response_code":200,"success":true}
{"added":1,"response_code":200,"success":true}

faceset/set_info
--Tv1GuN3gNeYpm0OQUDUYSPoe3R4MHRYO
Content-Disposition: form-data; name="faceset_name"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

faceset_n0
--Tv1GuN3gNeYpm0OQUDUYSPoe3R4MHRYO
Content-Disposition: form-data; name="tag"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

china tag_0
--Tv1GuN3gNeYpm0OQUDUYSPoe3R4MHRYO--
{"tag":"china tag_0","faceset_id":"5a9afe6e37572a61da037a087a5f3af0","response_code":200,"faceset_name":"faceset_n0"}
--dbapSeQx8x0XXS5gd5AGndlbN88eFSFL
Content-Disposition: form-data; name="faceset_name"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

faceset_n1
--dbapSeQx8x0XXS5gd5AGndlbN88eFSFL
Content-Disposition: form-data; name="tag"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

china tag_1
--dbapSeQx8x0XXS5gd5AGndlbN88eFSFL--
{"tag":"china tag_1","faceset_id":"baa1033fb49170da94458c179cd38588","response_code":200,"faceset_name":"faceset_n1"}
--S90zd2KHGeieRQ8D8OMUW_b7Gyuz3uXa
Content-Disposition: form-data; name="faceset_name"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

faceset_n2
--S90zd2KHGeieRQ8D8OMUW_b7Gyuz3uXa
Content-Disposition: form-data; name="tag"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

china tag_2
--S90zd2KHGeieRQ8D8OMUW_b7Gyuz3uXa--
{"tag":"china tag_2","faceset_id":"99311637228fdb3813e38dbed7950d18","response_code":200,"faceset_name":"faceset_n2"}

faceset/get_info
{"face":[{"tag":"","face_id":"beb41e45943f1ca51cfeaf9d5e17807e"}],"tag":"china tag_0","faceset_id":"5a9afe6e37572a61da037a087a5f3af0","response_code":200,"faceset_name":"faceset_n0"}
{"face":[{"tag":"","face_id":"f04841f32fecef9846be4970c58e72c1"}],"tag":"china tag_1","faceset_id":"baa1033fb49170da94458c179cd38588","response_code":200,"faceset_name":"faceset_n1"}
{"face":[{"tag":"","face_id":"4d51486ae5d9777bc229f429c1ebf3bb"}],"tag":"china tag_2","faceset_id":"99311637228fdb3813e38dbed7950d18","response_code":200,"faceset_name":"faceset_n2"}

group/create
{"group_name":"group0","tag":"","added_person":0,"response_code":200,"group_id":"6a98dbe1346d0c3327389b31e3b8bfec"}

group/add_person
--1CyoBlv4h_VP2BhNJRcFo5wA_UXWQVqU
Content-Disposition: form-data; name="group_name"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

group0
--1CyoBlv4h_VP2BhNJRcFo5wA_UXWQVqU
Content-Disposition: form-data; name="person_name"
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

person_n0,person_n1,person_n2
--1CyoBlv4h_VP2BhNJRcFo5wA_UXWQVqU--
{"added":3,"response_code":200,"success":true}

group/set_info
{"group_name":"group0","tag":"group tag","response_code":200,"group_id":"6a98dbe1346d0c3327389b31e3b8bfec"}

group/get_info
{"group_name":"group0","person":[{"person_id":"154c612b9e1cfaad936c92eefbe24f09","person_name":"person_n0","tag":"china tag_0"},{"person_id":"47f550e53f93e9178597c5868499e269","person_name":"person_n1","tag":"china tag_1"},{"person_id":"f00bc296dc526ffc27ee8a4e2fe634a1","person_name":"person_n2","tag":"china tag_2"}],"tag":"group tag","response_code":200,"group_id":"6a98dbe1346d0c3327389b31e3b8bfec"}

train/Identify
{"session_id":"429dd92f7ca645b380ad86a4ab5f21cf","response_code":200}
{"result":{"success":true},"session_id":"429dd92f7ca645b380ad86a4ab5f21cf","status":"SUCC","finish_time":1434564464,"response_code":200,"create_time":1434564463}

train/verify
{"result":{"success":true},"session_id":"a1e89bd8d7444bbc83c3aafe2b2694f2","status":"SUCC","finish_time":1434564466,"response_code":200,"create_time":1434564465}
{"result":{"success":true},"session_id":"503f7cb4c8e448598a566b735d51238e","status":"SUCC","finish_time":1434564466,"response_code":200,"create_time":1434564466}
{"result":{"success":true},"session_id":"d2b886a31d1b494187ef8c54278ca8a6","status":"SUCC","finish_time":1434564467,"response_code":200,"create_time":1434564463}

recognition/identify
{"face":[{"position":{"mouth_right":{"y":22.793561,"x":52.058537},"mouth_left":{"y":23.352927,"x":45.069268},"center":{"y":19.756098,"x":48.04878},"height":14.634146,"width":14.634146,"nose":{"y":20.744732,"x":47.626829},"eye_left":{"y":16.864756,"x":44.421707},"eye_right":{"y":16.01322,"x":51.597561}},"face_id":"b61e98330d0bc090c8d03aea80ec595a","candidate":[{"person_id":"f00bc296dc526ffc27ee8a4e2fe634a1","person_name":"person_n2","tag":"china tag_2","confidence":12.402992},{"person_id":"154c612b9e1cfaad936c92eefbe24f09","person_name":"person_n0","tag":"china tag_0","confidence":0.036911},{"person_id":"47f550e53f93e9178597c5868499e269","person_name":"person_n1","tag":"china tag_1","confidence":0}]}],"session_id":"20ec896b075b4735b573177e6aeb1d96","response_code":200}

recognition/verify
{"session_id":"94a40e505c1b4cbb9b22d00f28eb45c3","response_code":200,"confidence":99.999992,"is_same_person":true}
{"session_id":"65eb4f0dfd4e426db131646d29813c32","response_code":200,"confidence":95.433533,"is_same_person":false}

info/get_app
{"description":"deprecated","response_code":200,"name":"deprecated","info":"deprecated"}

info/get_app
{"face_info":[{"position":{"mouth_right":{"y":38.653894,"x":80.023902},"mouth_left":{"y":39.814953,"x":71.609512},"center":{"y":33.800623,"x":75.243902},"height":20.872274,"width":16.341463,"nose":{"y":34.450156,"x":74.298293},"eye_left":{"y":30.187726,"x":70.736585},"eye_right":{"y":28.659252,"x":78.349268}},"person":[{"person_id":"154c612b9e1cfaad936c92eefbe24f09","person_name":"person_n0","tag":"china tag_0"}],"img_id":"8b54680a72bc8da8c6550e4ca84a833a","tag":"","face_id":"beb41e45943f1ca51cfeaf9d5e17807e","attribute":{"age":{"range":10,"value":40},"gender":{"value":"Female","confidence":99.9985},"race":{"value":"White","confidence":58.3153},"smiling":{"value":98.7239}},"faceset":[{"tag":"china tag_0","faceset_id":"5a9afe6e37572a61da037a087a5f3af0","faceset_name":"faceset_n0"}],"url":"http://cn.faceplusplus.com/wp-content/themes/faceplusplus/assets/img/demo/11.jpg"}],"response_code":200}

info/get_group_list
{"response_code":200,"group":[{"group_name":"group0","tag":"group tag","group_id":"6a98dbe1346d0c3327389b31e3b8bfec"},{"group_name":"group_0","tag":"group tag","group_id":"b0abd285e63c777c07cda99b26e50e2d"}]}

info/get_image
{"face":[{"position":{"mouth_right":{"y":38.653894,"x":80.023902},"mouth_left":{"y":39.814953,"x":71.609512},"center":{"y":33.800623,"x":75.243902},"height":20.872274,"width":16.341463,"nose":{"y":34.450156,"x":74.298293},"eye_left":{"y":30.187726,"x":70.736585},"eye_right":{"y":28.659252,"x":78.349268}},"tag":"","face_id":"beb41e45943f1ca51cfeaf9d5e17807e"},{"position":{"mouth_right":{"y":51.956386,"x":25.697317},"mouth_left":{"y":53.221807,"x":17.340268},"center":{"y":47.352025,"x":21.707317},"height":20.560748,"width":16.097561,"nose":{"y":48.353271,"x":22.029073},"eye_left":{"y":43.312773,"x":17.307927},"eye_right":{"y":42.598442,"x":25.091707}},"tag":"","face_id":"f04841f32fecef9846be4970c58e72c1"},{"position":{"mouth_right":{"y":35.692212,"x":50.440244},"mouth_left":{"y":37.578193,"x":44.245854},"center":{"y":31.775701,"x":46.585366},"height":18.691589,"width":14.634146,"nose":{"y":32.875078,"x":46.454878},"eye_left":{"y":28.394268,"x":42.39439},"eye_right":{"y":26.697383,"x":49.860976}},"tag":"","face_id":"4d51486ae5d9777bc229f429c1ebf3bb"}],"img_id":"8b54680a72bc8da8c6550e4ca84a833a","response_code":200,"url":"http://cn.faceplusplus.com/wp-content/themes/faceplusplus/assets/img/demo/11.jpg"}

info/get_person_nlist
{"person":[{"person_id":"dceb4c69c919da72c319deeeac93cf55","person_name":"persons_0","tag":"中文 tag_0"},{"person_id":"ba938ae42a3953054c25840364d2a867","person_name":"persons_10","tag":"中文 tag_10"},{"person_id":"cdc32bc2833d8d41ec2e2e6d52b96f7d","person_name":"persons_2","tag":"中文 tag_2"},{"person_id":"2e572cf7754cdf93cb4732c47140aafb","person_name":"persons_3","tag":"中文 tag_3"},{"person_id":"7e79bcd43eda231415d86ea903fc0638","person_name":"persons_4","tag":"中文 tag_4"},{"person_id":"0fb405a196b00f9f57d3bc30d4f17abf","person_name":"persons_5","tag":"中文 tag_5"},{"person_id":"950854426c52835476297cec64248432","person_name":"persons_6","tag":"中文 tag_6"},{"person_id":"f8521d36cb1d6fd8127eacabb5ee194d","person_name":"persons_7","tag":"中文 tag_7"},{"person_id":"6967cdb9e3b16e71b3448e5c20df3d8d","person_name":"persons_8","tag":"中文 tag_8"},{"person_id":"f751101e9a3f78327cc166da87b26b0e","person_name":"persons_9","tag":"中文 tag_9"},{"person_id":"630906d51468ac3b2b2786ef7c6995c0","person_name":"person_0","tag":"涓枃 tag_0"},{"person_id":"154c612b9e1cfaad936c92eefbe24f09","person_name":"person_n0","tag":"china tag_0"},{"person_id":"47f550e53f93e9178597c5868499e269","person_name":"person_n1","tag":"china tag_1"},{"person_id":"f00bc296dc526ffc27ee8a4e2fe634a1","person_name":"person_n2","tag":"china tag_2"},{"person_id":"2aaaff168c24dbbb88514a7ae0f50cad","person_name":"person_s0","tag":"中文 tag_0"},{"person_id":"d6fe140f5b73e26f7c520a93a665d896","person_name":"pperson_0","tag":""},{"person_id":"4adb6a5cdf42ede9ed5822ccf5c8a3fe","person_name":"pperson_1","tag":""},{"person_id":"d4e6fe639bade5fab756e3d340ecee01","person_name":"pperson_10","tag":""},{"person_id":"5d5cbb4d7914db404b1db4742bd91f73","person_name":"pperson_2","tag":""},{"person_id":"eb4bbc069e0dac9bd1f1a40281a02f2f","person_name":"pperson_3","tag":""},{"person_id":"03840c3476dad21c556f99835b580b58","person_name":"pperson_4","tag":""},{"person_id":"230f20d53a62901d5e1d0d751e0715c5","person_name":"pperson_5","tag":""},{"person_id":"0bff30fd5f1777f2f2d9a6bcff232d06","person_name":"pperson_6","tag":""},{"person_id":"93ebe968d849e719cc59e0137fcd5e35","person_name":"pperson_7","tag":""},{"person_id":"22bc45061ec9526a24a2ef26208d912a","person_name":"pperson_8","tag":""},{"person_id":"4c595d08a69a9acd76b02199d29eb11c","person_name":"pperson_9","tag":""}],"response_code":200}

info/get_quota
{"total":0,"response_code":200,"exceed":0,"used":0,"info":"deprecated"}

info/get_session
{"result":{"face":[{"position":{"mouth_right":{"y":38.653894,"x":80.023902},"mouth_left":{"y":39.814953,"x":71.609512},"center":{"y":33.800623,"x":75.243902},"height":20.872274,"width":16.341463,"nose":{"y":34.450156,"x":74.298293},"eye_left":{"y":30.187726,"x":70.736585},"eye_right":{"y":28.659252,"x":78.349268}},"tag":"","face_id":"beb41e45943f1ca51cfeaf9d5e17807e","attribute":{"age":{"range":10,"value":40},"gender":{"value":"Female","confidence":99.9985},"race":{"value":"White","confidence":58.3153},"smiling":{"value":98.7239}}},{"position":{"mouth_right":{"y":51.956386,"x":25.697317},"mouth_left":{"y":53.221807,"x":17.340268},"center":{"y":47.352025,"x":21.707317},"height":20.560748,"width":16.097561,"nose":{"y":48.353271,"x":22.029073},"eye_left":{"y":43.312773,"x":17.307927},"eye_right":{"y":42.598442,"x":25.091707}},"tag":"","face_id":"f04841f32fecef9846be4970c58e72c1","attribute":{"age":{"range":5,"value":33},"gender":{"value":"Female","confidence":99.9999},"race":{"value":"White","confidence":97.3218},"smiling":{"value":99.5768}}},{"position":{"mouth_right":{"y":35.692212,"x":50.440244},"mouth_left":{"y":37.578193,"x":44.245854},"center":{"y":31.775701,"x":46.585366},"height":18.691589,"width":14.634146,"nose":{"y":32.875078,"x":46.454878},"eye_left":{"y":28.394268,"x":42.39439},"eye_right":{"y":26.697383,"x":49.860976}},"tag":"","face_id":"4d51486ae5d9777bc229f429c1ebf3bb","attribute":{"age":{"range":8,"value":16},"gender":{"value":"Female","confidence":99.9936},"race":{"value":"White","confidence":99.0117},"smiling":{"value":51.1197}}}],"img_id":"8b54680a72bc8da8c6550e4ca84a833a","img_height":321,"img_width":410,"url":"http://cn.faceplusplus.com/wp-content/themes/faceplusplus/assets/img/demo/11.jpg"},"session_id":"d53921e468bb483a8d40cf2898a992ef","status":"SUCC","response_code":200,"finish_time":1434564459,"create_time":1434564455}

person/remove_face
{"response_code":200,"removed":1,"success":true}

group/delete
{"response_code":200,"success":true,"deleted":1}

person/delete
{"response_code":200,"success":true,"deleted":1}

faceset/delete
{"response_code":200,"success":true,"deleted":1}
时间: 2024-11-05 13:03:53

Face++ Java 简单实例的相关文章

Selenium WebDriver java 简单实例

开发环境 JDK 下载地址: http://www.oracle.com/technetwork/java/javase/downloads/index.html Eclipse: 下载地址:http://www.eclipse.org/downloads/ Selenium jar包 (这里用的是:selenium-Java-2.45.0.zip ,selenium-server-standalone-2.45.0.jar) 下载地址:http://code.google.com/p/sele

Java简单实例--小超市

import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; class Product{ privat

Eclipse运行Java简单实例

运行eclipse前首先配置好JDK环境变量等  双击这句话可跳转配置环境变量详细步骤 运行eclipse软件 1.File菜单-New - project 2.Java Project - Next 3.Project name 项目名:Test  首字母大写 =>Finish 4.右击src 新建一个包Package (包名尽量小写) package => yin=>Finish 5.右击新建好的yin包   New-Class 创建一个Class类 Name为第一个程序  firs

JAVA RMI远程方法调用简单实例[转]

RMI的概念 RMI(Remote Method Invocation)远程方法调用是一种计算机之间利用远程对象互相调用实现双方通讯的一种通讯机制.使用这种机制,某一台计算机上的对象可以调用另外 一台计算机上的对象来获取远程数据.RMI是Enterprise JavaBeans的支柱,是建立分布式Java应用程序的方便途径.在过去,TCP/IP套接字通讯是远程通讯的主要手段,但此开发方式没有使用面向对 象的方式实现开发,在开发一个如此的通讯机制时往往令程序员感觉到乏味,对此RPC(Remote

主题:Java WebService 简单实例

链接地址:主题:Java WebService 简单实例    http://www.iteye.com/topic/1135747 前言:朋友们开始以下教程前,请先看第五大点的注意事项,以避免不必要的重复操作. 一.准备工作(以下为本实例使用工具) 1.MyEclipse10.7.1 2.JDK 1.6.0_22 二.创建服务端 1.创建[Web Service Project],命名为[TheService].   2.创建[Class]类,命名为[ServiceHello],位于[com.

java网页爬虫简单实例详解——获取天气预报。

[本文介绍] 爬取别人网页上的内容,听上似乎很有趣的样子,只要几步,就可以获取到力所不能及的东西,例如呢?例如天气预报,总不能自己拿着仪器去测吧!当然,要获取天气预报还是用webService好.这里只是举个例子.话不多说了,上看看效果吧. [效果] 我们随便找个天气预报的网站来试试:http://www.weather.com.cn/html/weather/101280101.shtml 从图中可用看出,今天(6日)的天气.我们就以这个为例,获取今天的天气吧! 最终后台打印出: 今天:6日

Java 多线程 简单实例 (消费者与生成者)的关系

PS::线程这套东西在PHP里完全是不存在的概念,有待进一步的学习: PS::这个实例是根据书本上的知识进行扩展的,理解程度50%左右吧! 1.定义生产消费环境 package second; public class Queue { int value = 0; boolean isEmpty = true; /** * 生产者 * @param v */ public synchronized void put(int v){ if(!isEmpty){//如果存在数据没有被消费 try{

session 对象的简单实例

一个session对象的简单实例: 1.登录界面:使用简单的html表单提交界面. <%@ page language="java" contentType="text/html; charset=GB18030"    pageEncoding="GB18030"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "ht

javamail发送邮件的简单实例(转)

javamail发送邮件的简单实例 今天学习了一下JavaMail,javamail发送邮件确实是一个比较麻烦的问题.为了以后使用方便,自己写了段代码,打成jar包,以方便以后使用.呵呵 以下三段代码是我的全部代码,朋友们如果想用,直接复制即可. 第一个类:MailSenderInfo.java package com.util.mail;    /**    * 发送邮件需要使用的基本信息  *author by wangfun http://www.5a520.cn 小说520   */