Face++ 第三方类库的使用文档

来源:互联网 发布:java软件编程培训中心 编辑:程序博客网 时间:2024/06/10 21:18

Face++主要实现人脸的扫描,定位五官位置。判断微笑程度,年龄等。

实现人脸识别等。

下载地址:http://www.faceplusplus.com.cn

以下是对此类库的使用笔记


//

//  RootViewController.m

//  FacePlusPlusDemo_and_SDK

//

//  Created by lihao on 14-3-26.

//  Copyright (c) 2014 lihao All rights reserved.

//


#import "RootViewController.h"

#import "APIKey+APISecret.h"

#import "FaceppAPI.h"


@interface RootViewController ()

{

   UIImage * _image;

   UIImage * _image2;

}

@property(nonatomic,retain)UIImageView * imageView;


@end


@implementation RootViewController


-(void)dealloc{

    [self.imageViewrelease];

    [superdealloc];

}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

   self = [superinitWithNibName:nibNameOrNil bundle:nibBundleOrNil];

   if (self) {

        // Custom initialization

       _image = [UIImageimageNamed:@"face.jpg"];

        _image2 = [UIImageimageNamed:@"5E151821891.jpg"];

    }

    return self;

}


- (void)viewDidLoad

{

    [superviewDidLoad];

// Do any additional setup after loading the view.

    

//添加到UIImageView上,方便框出脸部等

   self.imageView = [[UIImageViewalloc]initWithFrame:CGRectMake(10,0, 150, _image.size.height/(_image.size.width/150))];

    [_imageView setImage:_image];

    [self.viewaddSubview:_imageView];

    [_imageView release];

    

    UIButton * firstButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [firstButtonsetFrame:CGRectMake(10,200, 150, 30)];

    [firstButton setBackgroundColor:[UIColoryellowColor]];

    [firstButton setTitle:@"/detection/detect"forState:UIControlStateNormal];

    [firstButton addTarget:selfaction:@selector(firstButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:firstButton];

    

    UIButton * secondButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [secondButtonsetFrame:CGRectMake(10,250, 150, 30)];

    [secondButton setBackgroundColor:[UIColoryellowColor]];

    [secondButton setTitle:@"/detection/landmark"forState:UIControlStateNormal];

    [secondButton addTarget:selfaction:@selector(secondButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:secondButton];

    

    UIButton * thirdButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [thirdButtonsetFrame:CGRectMake(10,300, 150, 30)];

    [thirdButton setBackgroundColor:[UIColoryellowColor]];

    [thirdButton setTitle:@"/group/create/delete"forState:UIControlStateNormal];

    [thirdButton addTarget:selfaction:@selector(thirdButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:thirdButton];

    

    UIButton * forthButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [forthButtonsetFrame:CGRectMake(10,350, 150, 30)];

    [forthButton setBackgroundColor:[UIColoryellowColor]];

    [forthButton setTitle:@"/person/create/delete"forState:UIControlStateNormal];

    [forthButton addTarget:selfaction:@selector(forthButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:forthButton];

    

    UIButton * fifthButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [fifthButtonsetFrame:CGRectMake(10,400, 150, 30)];

    [fifthButton setBackgroundColor:[UIColoryellowColor]];

    [fifthButton setTitle:@"/per/add/rem/face"forState:UIControlStateNormal];

    [fifthButton addTarget:selfaction:@selector(fifthButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:fifthButton];

    

    UIButton * sixButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [sixButtonsetFrame:CGRectMake(10,450, 150, 30)];

    [sixButton setBackgroundColor:[UIColoryellowColor]];

    [sixButton setTitle:@"/person/get_info"forState:UIControlStateNormal];

    [sixButton addTarget:selfaction:@selector(sixButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:sixButton];


    UIButton * sevenButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [sevenButtonsetFrame:CGRectMake(10,500, 150, 30)];

    [sevenButton setBackgroundColor:[UIColoryellowColor]];

    [sevenButton setTitle:@"/person/set_info"forState:UIControlStateNormal];

    [sevenButton addTarget:selfaction:@selector(sevenButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:sevenButton];

    

    UIButton * eightButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [eightButtonsetFrame:CGRectMake(170,200, 140, 30)];

    [eightButton setBackgroundColor:[UIColoryellowColor]];

    [eightButton setTitle:@"/group/add_person"forState:UIControlStateNormal];

    [eightButton addTarget:selfaction:@selector(eightButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:eightButton];

    

    UIButton * nineButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [nineButtonsetFrame:CGRectMake(170,250, 140, 30)];

    [nineButton setBackgroundColor:[UIColoryellowColor]];

    [nineButton setTitle:@"/group/remove/etc"forState:UIControlStateNormal];

    [nineButton addTarget:selfaction:@selector(nineButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:nineButton];

    

    UIButton * tenButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [tenButtonsetFrame:CGRectMake(170,300, 140, 30)];

    [tenButton setBackgroundColor:[UIColoryellowColor]];

    [tenButton setTitle:@"/recognition/compare"forState:UIControlStateNormal];

    [tenButton addTarget:selfaction:@selector(tenButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:tenButton];

    

    UIButton * elevenButton = [UIButtonbuttonWithType:UIButtonTypeSystem];

    [elevenButtonsetFrame:CGRectMake(170,350, 140, 30)];

    [elevenButton setBackgroundColor:[UIColoryellowColor]];

    [elevenButton setTitle:@"/recognition/verify"forState:UIControlStateNormal];

    [elevenButton addTarget:selfaction:@selector(elevenButtonClick:)forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:elevenButton];

}


-(void)firstButtonClick:(id)sender{

/**************************************************************************************

    检测给定图片(Image)中的所有人脸(Face)的位置和相应的面部属性

    attribute-可以是none或者由逗号分割的属性列表。默认为gender, age, race, smiling。目前支持的属性包括:gender, age, race, smiling, glass, pose

    mode-检测模式可以是normal(默认)或者 oneface 。在oneface模式中,检测器仅找出图片中最大的一张脸

    tag-可以为图片中检测出的每一张Face指定一个不包含^@,&=*'"等非法字符且不超过255字节的字符串作为tagtag信息可以通过 /info/get_face 查询

    async-如果置为true,该API将会以异步方式被调用;也就是立即返回一个session id,稍后可通过/info/get_session查询结果。默认值为false

**************************************************************************************/

    

    FaceppResult * result = [[FaceppAPIdetection] detectWithURL:nilorImageData:UIImageJPEGRepresentation(_image,1) mode:FaceppDetectionModeNormalattribute:FaceppDetectionAttributeAlltag:nilasync:NO];

    [resultsuccess];

    

/**************************************************************************************

     2014-03-26 09:16:23.786 FaceTechnology[21492:70b] [FacePlusPlus]request url:

     https://apicn.faceplusplus.com/v2/detection/detect?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&mode=normal&attribute=age

     2014-03-26 09:16:25.468 FaceTechnology[21492:70b] [FacePlusPlus]response JSON:

     {

     "face": [                  被检测出的人脸的列表

     {

     "attribute": {             包含一系列人脸的属性分析结果

     "age": {               包含年龄分析结果,value的值为一个非负整数表示估计的年龄, range表示估计年龄的正负区间

     "range": 5,

     "value": 2

     },

     "gender": {            包含性别分析结果,value的值为Male/Female, confidence表示置信度

     "confidence": 99.7306,

     "value": "Female"

     },

     "race": {              包含人种分析结果,value的值为Asian/White/Black, confidence表示置信度

     "confidence": 70.0173,

     "value": "White"

     },

     "smiling": {           包含微笑程度分析结果,value的值为0100的实数,越大表示微笑程度越高

     "value": 2.929

     }

     glass object

     包含眼镜佩戴分析结果,value的值为None/Dark/Normal, confidence表示置信度

     pose object

     包含脸部姿势分析结果,包括pitch_angle, roll_angle, yaw_angle,分别对应抬头,旋转(平面旋转),摇头。单位为角度。

     },

     "face_id": "21b75510f27f6b2be74caada6b29052e",  被检测出的每一张人脸都在Face++系统中的标识符

     "position": {

     "center": {               检出的人脸框的中心点坐标, x & y坐标分别表示在图片中的宽度和高度的百分比 (0~100之间的实数)

     "x": 41.683168,

     "y": 62.583333

     },

     "eye_left": {              相应人脸的左眼坐标,x & y坐标分别表示在图片中的宽度和高度的百分比 (0~100之间的实数)

     "x": 32.432673,

     "y": 50.813833

     },

     "eye_right": {             相应人脸的右眼坐标,x & y坐标分别表示在图片中的宽度和高度的百分比 (0~100之间的实数)

     "x": 64.77604,

     "y": 51.9925

     },

     "height": 47.5,            0~100之间的实数,表示检出的脸的高度在图片中百分比

     "mouth_left": {            相应人脸的左侧嘴角坐标,x & y坐标分别表示在图片中的宽度和高度的百分比 (0~100之间的实数)

     "x": 35.18,

     "y": 76.711167

     },

     "mouth_right": {           相应人脸的右侧嘴角坐标,x & y坐标分别表示在图片中的宽度和高度的百分比 (0~100之间的实数)

     "x": 59.17703,

     "y": 78.1525

     },

     "nose": {                  相应人脸的鼻尖坐标,x & y坐标分别表示在图片中的宽度和高度的百分比 (0~100之间的实数)

     "x": 48.812277,

     "y": 61.816667

     },

     "width": 56.435644         0~100之间的实数,表示检出的脸的宽度在图片中百分比

     },

     "tag": ""

     }

     ],

     "img_height": 654,                                请求图片的高度

     "img_id": "e732954b2592238ad7865c666e1703a9",     Face++系统中的图片标识符,用于标识用户请求中的图片

     "img_width": 551,                                 请求图片的宽度

     "session_id": "e3aefa2e9dde42f4b4a5281efff16684", 相应请求的session标识符,可用于结果查询

     "url": null                                       请求中图片的url

     }

     *************************************************************************************

     错误列表:

     

     错误代码HTTP 状态代码错误信息

     1001 500 INTERNAL_ERROR

     1003 403 AUTHORIZATION_ERROR

     1003 403 INSUFFICIENT_PRIVILEGE_OR_QUOTA_LIMIT_EXCEEDED

     1004 400 MISSING_ARGUMENTS

     1005 400 INVALID_ARGUMENTS

     1006 403 ILLEGAL_USE_OF_DEMO_KEY

     1202 502 SERVER_TOO_BUSY

     1301 431 IMAGE_ERROR_UNSUPPORTED_FORMAT

     1302 432 IMAGE_ERROR_FAILED_TO_DOWNLOAD

     1303 433 IMAGE_ERROR_FILE_TOO_LARGE

     1304 434 IMAGE_ERROR

     1502 452 BAD_TAG

**************************************************************************************/

}


-(void)secondButtonClick:(id)sender{

/***************************************************************************************

    检测给定人脸(Face)相应的面部轮廓,五官等关键点的位置,包括25点和83点两种模式。

    此方法默认同步

    https://apicn.faceplusplus.com/v2/detection/landmark?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&face_id=21b75510f27f6b2be74caada6b29052e&type=25p

 

     session_id string相应请求的session标识符,可用于结果查询

     face_id string人脸在Face++系统中的标识符

     landmark object

     包含详细关键点分析结果,包含多个关键点的坐标。

****************************************************************************************/

    

    FaceppResult * result = [[FaceppAPIdetection] landmarkWithFaceId:[selfgetFace_idOnPhoto:_image]andType:FaceppLandmark25P];

    [resultsuccess];

//    if ([result success]) {

//        NSDictionary * dic = [NSDictionary dictionaryWithDictionary:[[[[result content] objectForKey:@"result"]objectAtIndex:0]objectForKey:@"landmark"]];

//        NSLog(@"%@",dic);

//        

//    }


}


-(void)thirdButtonClick:(id)sender{

/****************************************************************************************

    创建一个组

    roup_name-GroupName信息,必须在App中全局唯一。Name不能包含^@,&=*'"等非法字符,且长度不得超过255Name也可以不指定,此时系统将产生一个随机的name

 

    tag-Grouptag,不需要全局唯一,不能包含^@,&=*'"等非法字符,长度不能超过255

    person_id person_name一组用逗号分隔的person_idperson_name,表示将这些Person加入到该Group中。注意,一个Person可以被加入到多个Group中。

    返回值

    added_person int     成功加入的person数量

    tag             string group相关的tag

    group_name      string 相应groupname

    group_id        string 相应groupid

****************************************************************************************/

    

    FaceppResult * result = [[FaceppAPIgroup]createWithGroupName:@"FirstGroup"];

    [resultsuccess];

    

    

/****************************************************************************************

 删除一个组

 group_name group_id一组用逗号分割的group_idgroup_name,表示删除这些Group

 

 deleted     int     成功删除的group数量

 success     bool 表示操作是否成功

 ****************************************************************************************/

    

    FaceppResult * result2 = [[FaceppAPIgroup]deleteWithGroupName:@"SecondGroup"orGroupId:nil];

    [result2success];

}


-(void)forthButtonClick:(id)sender{

/****************************************************************************************

 添加personGroup

 person_name PersonName信息,必须在App中全局唯一。Name不能包含^@,&=*'"等非法字符,且长度不得超过255Name也可以不指定,此时系统将产生一个随机的name

 face_id 一组用逗号分隔的face_id,表示将这些Face加入到该Person

 tag        Person相关的tag,不需要全局唯一,不能包含^@,&=*'"等非法字符,长度不能超过255

 group_id group_name一组用逗号分割的group id列表或者group name列表。如果该参数被指定,该Personcreate之后就会被加入到这些组中。

 https://apicn.faceplusplus.com/v2/person/create?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&person_name=lihao4&group_name=MyFirstGroup&face_id=21b75510f27f6b2be74caada6b29052e

 ****************************************************************************************/

    [[FaceppAPIperson]createWithPersonName:@"people1"andFaceId:@[[selfgetFace_idOnPhoto:_image]]andTag:NilandGroupId:nilorGroupName:@[@"FirstGroup"]];

    

/****************************************************************************************

 删除组中的某个人

 https://apicn.faceplusplus.com/v2/person/delete?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&person_name=lihao2

****************************************************************************************/

    

    [[FaceppAPIperson]deleteWithPersonName:@"people2"orPersonId:Nil];

    

}


-(void)fifthButtonClick:(id)sender{

/****************************************************************************************

 将一组Face加入到一个Person中。注意,一个Face只能被加入到一个Person中。

 person_name person_id相应Personname或者id

 face_id                    一组用逗号分隔的face_id,表示将这些Face加入到相应Person中。

 

 added      int             成功加入的face数量

 success bool            表示操作是否成功

 https://apicn.faceplusplus.com/v2/person/add_face?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&face_id=21b75510f27f6b2be74caada6b29052e&person_name=lihao3

 ****************************************************************************************/

    [[FaceppAPIperson]addFaceWithPersonName:@"people1"orPersonId:NilandFaceId:@[[selfgetFace_idOnPhoto:_image]]];

    

/****************************************************************************************

 删除Person中的一个或多个Face

 person_name person_id    相应Personname或者id

 face_id                     一组用逗号分隔的face_id列表,表示将这些face从该Person中删除。开发者也可以指定face_id=all,表示删除该Person所有相关Face

 

 removed int             成功删除的face数量

 success bool            表示操作是否成功

 https://apicn.faceplusplus.com/v2/person/remove_face?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&person_name=lihao1&face_id=21b75510f27f6b2be74caada6b29052e

 ****************************************************************************************/

    

    [[FaceppAPIperson]removeFaceWithPersonName:@"people2"orPersonId:NilandFaceId:@[[selfgetFace_idOnPhoto:_image]]];

    

}


-(void)sixButtonClick:(id)sender{

/****************************************************************************************

 获取一个Person的信息,包括name, id, tag, 相关的face, 以及groups等信息

 tag            string person相关的tag

 person_name string相应personname

 person_id      string 相应personid

 

 https://apicn.faceplusplus.com/v2/person/get_info?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&person_name=lihao3

 ****************************************************************************************/

    [[FaceppAPIperson]getInfoWithPersonName:@"people1"orPersonId:Nil];

    

}


-(void)sevenButtonClick:(id)sender{

/****************************************************************************************

 设置Personnametag

 person_id person_name相应Personidname

 name                       新的name

 tag                        新的tag

 

 tag            string      person相关的tag

 person_name string      相应personname

 person_id      string      相应personid

 

 https://apicn.faceplusplus.com/v2/person/set_info?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&person_name=lihao3&name=lihaonewName1

 ****************************************************************************************/

    [[FaceppAPIperson]setInfoWithPersonName:@"people2"orPersonId:NilandName:@"newnamepeople2"andTag:Nil];

    

}


-(void)eightButtonClick:(id)sender{

/****************************************************************************************

 将一组Person加入到一个Group中。

 group_id group_name      相应Groupidname

 person_id person_name一组用逗号分隔的person_idperson_name,表示将这些Person加入到相应Group中。

 

 added      int     成功加入的person数量

 success bool 表示操作是否成功

 

 https://apicn.faceplusplus.com/v2/person/set_info?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&person_name=lihao3&name=lihaonewName1

 ****************************************************************************************/

    [[FaceppAPIgroup]addPersonWithGroupId:nilorGroupName:@"FirstGroup"andPersonId:nilorPersonName:@[@"people1"]];

    

}


-(void)nineButtonClick:(id)sender{

/****************************************************************************************

 Group中删除一组Person

 group_id   group_name相应Groupidname

 person_id  person_name一组用逗号分割的person_id列表或者person_name列表,表示将这些person从该Group中删除。开发者也可以指定person_id=all,表示删掉该Group中所有Person

 

 removed int     成功删除的person数量

 success bool 表示操作是否成功

 

 https://apicn.faceplusplus.com/v2/group/remove_person?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&group_name=FirstGroup&person_name=people1

 ****************************************************************************************/

    

    [[FaceppAPIgroup]removePersonWithGroupName:@"FirstGroup"orGroupId:nilandPersonName:@[@"people2"]orPersonId:nil];

    

//    设置Groupnametag

//    [FaceppAPI group]setInfoWithGroupId:<#(NSString *)#> orGroupName:<#(NSString *)#> andName:<#(NSString *)#> andTag:<#(NSString *)#>

    

//  获取Group的信息,包括Group中的Person列表,Grouptag等信息

    [[FaceppAPIgroup]getInfoWithGroupName:@"FirstGroup"orGroupId:nil];

//    [[FaceppAPI group]getInfoUngroupedPersons];

    

}


-(void)tenButtonClick:(id)sender{

/****************************************************************************************

 计算两个Face的相似性以及五官相似度

 face_id1 第一个Faceface_id

 face_id2 第二个Faceface_id

 async      如果置为true,该API将会以异步方式被调用;也就是立即返回一个session id,稍后可通过/info/get_session查询结果。默认值为false

 

 component_similarity object包含人脸中各个部位的相似性,目前包含eyebrow(眉毛)eye(眼睛)nose(鼻子)mouth(嘴)的相似性。每一项的值为一个0~100之间的实数,表示相应部位的相似性

 similarity             float   一个0~100之间的实数,表示两个face的相似性

 

 https://apicn.faceplusplus.com/v2/group/remove_person?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&group_name=FirstGroup&person_name=people1

 ****************************************************************************************/

    

    [[FaceppAPIrecognition]compareWithFaceId1:[selfgetFace_idOnPhoto:_image]andId2:[selfgetFace_idOnPhoto:_image2]async:NO];

    

}


-(void)elevenButtonClick:(id)sender{

/****************************************************************************************

 给定一个Face和一个Person,返回是否是同一个人的判断以及置信度。

 注意,当Person中的信息被修改之后(增加,删除了Face等),为了保证结果与最新数据一致,Person应当被重新train/train/verify 。否则调用此API时将使用最后一次train时的数据。

 face_id                    verifyface_id

 person_id person_name对应的Person

 async                      如果置为true,该API将会以异步方式被调用;也就是立即返回一个session id,稍后可通过/info/get_session查询结果。默认值为false

 

 is_same_person boolean     两个输入是否为同一人的判断

 confidence float           系统对这个判断的置信度。

 session_id string          相应请求的session标识符,可用于结果查询

 

 1001 500 INTERNAL_ERROR

 1003 403 AUTHORIZATION_ERROR

 1003 403 INSUFFICIENT_PRIVILEGE_OR_QUOTA_LIMIT_EXCEEDED

 1004 400 MISSING_ARGUMENTS

 1005 400 INVALID_ARGUMENTS

 1006 403 ILLEGAL_USE_OF_DEMO_KEY

 1202 502 SERVER_TOO_BUSY

 1401 441 OBJECT_UNTRAINED

 

 https://apicn.faceplusplus.com/v2/recognition/verify?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&face_id=d994aaa928d4a1fe08719e396d388cb6&person_name=people1

 ****************************************************************************************/

    

//对比前要针对verify功能对一个person进行训练

    [selfverifyForComparePhoto:nilorPersonName:@"people1"];

    

    [[FaceppAPIrecognition]verifyWithFaceId:[selfgetFace_idOnPhoto:_image]andPersonId:nilorPersonName:@"people1"async:NO];

}


-(void)verifyForComparePhoto:(NSString *)personId orPersonName:(NSString *)personName{

    /****************************************************************************************

     针对verify功能对一个person进行训练。请注意:

     

     在一个person内进行verify之前,必须先对该person进行Train

     当一个person内的数据被修改后(例如增删Person相关的Face),为使这些修改生效,person应当被重新Train

     Train所花费的时间较长, 因此该调用是异步的,仅返回session_id

     训练的结果可以通过/info/get_session查询。当训练完成时,返回值中将包含{"success": true}

     

     person_id person_name验证对象person

     session_id string          相应请求的session标识符,可用于结果查询

     

     https://apicn.faceplusplus.com/v2/train/verify?api_key=aa569c381b35696b1d43b502c14ed931&api_secret=1Yrs_Dz6dKtUAg8wBgXc56GspwKxqkt9&person_name=people1

     ****************************************************************************************/

    

   if (personId != nil) {

        [[FaceppAPItrain]trainAsynchronouslyWithId:personIdorName:nilandType:FaceppTrainVerify];

    }elseif (personName != nil){

        [[FaceppAPItrain]trainAsynchronouslyWithId:nilorName:@"people1"andType:FaceppTrainVerify];

    }else{

        NSLog(@"error data");

    }

}


//返回face_id

-(NSString *)getFace_idOnPhoto:(UIImage *)image{

    FaceppResult * result = [[FaceppAPIdetection] detectWithURL:nilorImageData:UIImageJPEGRepresentation(image,1) mode:FaceppDetectionModeNormalattribute:FaceppDetectionAttributeAlltag:nilasync:NO];

   if ([[[result content]objectForKey:@"face"]count]) {

       NSLog(@"succeed");

        return [[[[resultcontent] objectForKey:@"face"]objectAtIndex:0]valueForKeyPath:@"face_id"];

    }else{

       NSLog(@"error");

       return nil;

    }

}


- (void)didReceiveMemoryWarning

{

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end


0 0
原创粉丝点击