API extension for a new version 1.1
This commit is contained in:
Родитель
bf7687eb5f
Коммит
eaa51046c7
|
@ -48,6 +48,11 @@ typedef enum
|
|||
MPOFaceAttributeTypeHeadPose,
|
||||
} MPOFaceAttributeType;
|
||||
|
||||
typedef enum {
|
||||
MPOSimilarFaceSearchingModeMatchFace,
|
||||
MPOSimilarFaceSearchingModeMatchPerson
|
||||
} MPOSimilarFaceSearchingMode;
|
||||
|
||||
typedef void (^MPOCompletionBlock)(NSError *error);
|
||||
typedef void (^MPOFaceArrayCompletionBlock)(NSArray<MPOFace *> *collection, NSError *error);
|
||||
typedef void (^MPOSimilarFaceArrayCompletionBlock)(NSArray<MPOSimilarFace *> *collection, NSError *error);
|
||||
|
@ -100,15 +105,56 @@ typedef void (^MPOFaceListMetadataArrayCompletionBlock)(NSArray<MPOFaceListMetad
|
|||
*/
|
||||
- (NSURLSessionDataTask *)verifyWithFirstFaceId:(NSString *)faceId1 faceId2:(NSString *)faceId2 completionBlock:(void (^) (MPOVerifyResult *verifyResult, NSError *error))completion;
|
||||
|
||||
/**
|
||||
* Verifies whether the specified face belong to the specified person.
|
||||
* @param faceId the face Id
|
||||
* @param personId the person Id
|
||||
* @param completion completionHandler
|
||||
* @return the verification result, MPOVerifyResult
|
||||
*/
|
||||
- (NSURLSessionDataTask *)verifyWithFirstFaceId:(NSString *)faceId personId:(NSString *)personId completionBlock:(void (^) (MPOVerifyResult *verifyResult, NSError *error))completion;
|
||||
|
||||
/**
|
||||
* Finds the similar faces.
|
||||
* @param faceId The face identifier.
|
||||
* @param faceIds The face list identifier.
|
||||
* @param faceIds The list of face identifiers.
|
||||
* @param completion completionHandler
|
||||
* @return the similar faces, NSArray containg MPOSimilarFace
|
||||
*/
|
||||
- (NSURLSessionDataTask *)findSimilarWithFaceId:(NSString *)faceId faceIds:(NSArray *)faceIds completionBlock:(MPOSimilarFaceArrayCompletionBlock)completion;
|
||||
|
||||
/**
|
||||
* Finds the similar faces.
|
||||
* @param faceId The face identifier.
|
||||
* @param faceListId The face list identifier.
|
||||
* @param completion completionHandler
|
||||
* @return the similar faces, NSArray containg MPOSimilarFace
|
||||
*/
|
||||
- (NSURLSessionDataTask *)findSimilarWithFaceId:(NSString *)faceId faceListId:(NSString *)faceListId completionBlock:(MPOSimilarFaceArrayCompletionBlock)completion;
|
||||
|
||||
/**
|
||||
* Finds the similar faces.
|
||||
* @param faceId The face identifier.
|
||||
* @param faceIds The list of face identifiers.
|
||||
* @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. It defaults to 20.
|
||||
* @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". It defaults to "matchPerson".
|
||||
* @param completion completionHandler
|
||||
* @return the similar faces, NSArray containg MPOSimilarFace
|
||||
*/
|
||||
- (NSURLSessionDataTask *)findSimilarWithFaceId:(NSString *)faceId faceIds:(NSArray *)faceIds maxNumOfCandidatesReturned:(NSInteger)maxNumOfCandidatesReturned mode:(MPOSimilarFaceSearchingMode)mode completionBlock:(MPOSimilarFaceArrayCompletionBlock)completion;
|
||||
|
||||
/**
|
||||
* Finds the similar faces.
|
||||
* @param faceId The face identifier.
|
||||
* @param faceListId The face list identifier.
|
||||
* @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. It defaults to 20.
|
||||
* @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". It defaults to "matchPerson".
|
||||
* @param completion completionHandler
|
||||
* @return the similar faces, NSArray containg MPOSimilarFace
|
||||
*/
|
||||
- (NSURLSessionDataTask *)findSimilarWithFaceId:(NSString *)faceId faceListId:(NSString *)faceListId maxNumOfCandidatesReturned:(NSInteger)maxNumOfCandidatesReturned mode:(NSString*)mode completionBlock:(MPOSimilarFaceArrayCompletionBlock)completion;
|
||||
|
||||
|
||||
/**
|
||||
* Groups the faces.
|
||||
* @param faceIds the face ids.
|
||||
|
@ -118,7 +164,7 @@ typedef void (^MPOFaceListMetadataArrayCompletionBlock)(NSArray<MPOFaceListMetad
|
|||
- (NSURLSessionDataTask *)groupWithFaceIds:(NSArray *)faceIds completionBlock:(void (^) (MPOGroupResult *groupResult, NSError *error))completion;
|
||||
|
||||
/**
|
||||
* Identities the faces in a given person group.
|
||||
* Identities the faces in a given person group with the default confidence threshold of 0.7.
|
||||
* @param personGroupId the person group id
|
||||
* @param faceIds the face ids
|
||||
* @param maxNumberOfCandidates The maximum number of candidates returned for each face.
|
||||
|
@ -127,6 +173,17 @@ typedef void (^MPOFaceListMetadataArrayCompletionBlock)(NSArray<MPOFaceListMetad
|
|||
*/
|
||||
- (NSURLSessionDataTask *)identifyWithPersonGroupId:(NSString *)personGroupId faceIds:(NSArray *)faceIds maxNumberOfCandidates:(NSInteger)maxNumberOfCandidates completionBlock:(MPOIdentifyResultArrayCompletionBlock)completion;
|
||||
|
||||
/**
|
||||
* Identities the faces in a given person group.
|
||||
* @param personGroupId the person group id
|
||||
* @param faceIds the face ids
|
||||
* @param maxNumberOfCandidates The maximum number of candidates returned for each face.
|
||||
* @param confidenceThreshold The confidence threshold of identification.
|
||||
* @param completion completionHandler
|
||||
* @return the identification results, NSArray containing MPOIdentifyResult objects
|
||||
*/
|
||||
- (NSURLSessionDataTask *)identifyWithPersonGroupId:(NSString *)personGroupId faceIds:(NSArray *)faceIds maxNumberOfCandidates:(NSInteger)maxNumberOfCandidates confidenceThreshold:(CGFloat)confidenceThreshold completionBlock:(MPOIdentifyResultArrayCompletionBlock)completion;
|
||||
|
||||
|
||||
#pragma mark Person Groups APIs
|
||||
|
||||
|
@ -172,7 +229,23 @@ typedef void (^MPOFaceListMetadataArrayCompletionBlock)(NSArray<MPOFaceListMetad
|
|||
* @param completion completionHandler
|
||||
* @return person group entities, NSArray of MPOPersonGroup objects
|
||||
*/
|
||||
- (NSURLSessionDataTask *)getPersonGroupsWithCompletion:(MPOPersonGroupArrayCompletionBlock)completion;
|
||||
- (NSURLSessionDataTask *)getPersonGroupsWithCompletion:(MPOPersonGroupArrayCompletionBlock)completion NS_DEPRECATED_IOS(7.0, 7.0);
|
||||
|
||||
/**
|
||||
* Lists all person groups
|
||||
* @param completion completionHandler
|
||||
* @return person group entities, NSArray of MPOPersonGroup objects
|
||||
*/
|
||||
- (NSURLSessionDataTask *)listPersonGroupsWithCompletion:(MPOPersonGroupArrayCompletionBlock)completion;
|
||||
|
||||
/**
|
||||
* Lists all person groups
|
||||
* @start List person groups from the least personGroupId greater than the "start". It contains no more than 64 characters. Default is empty.
|
||||
* @top The number of person groups to list, ranging in [1, 1000]. Default is 1000.
|
||||
* @param completion completionHandler
|
||||
* @return person group entities, NSArray of MPOPersonGroup objects
|
||||
*/
|
||||
- (NSURLSessionDataTask *)listPersonGroupsWithStart:(NSString*)start top:(NSInteger)top completionBlock:(MPOPersonGroupArrayCompletionBlock)completion;
|
||||
|
||||
/**
|
||||
* Trains the person group
|
||||
|
@ -239,7 +312,16 @@ typedef void (^MPOFaceListMetadataArrayCompletionBlock)(NSArray<MPOFaceListMetad
|
|||
* @param completion completion handler
|
||||
* @return the persons, NSArray containing MPOPerson objects
|
||||
*/
|
||||
- (NSURLSessionDataTask *)getPersonsWithPersonGroupId:(NSString *)personGroupId completionBlock:(MPOPersonArrayCompletionBlock)completion;
|
||||
- (NSURLSessionDataTask *)getPersonsWithPersonGroupId:(NSString *)personGroupId completionBlock:(MPOPersonArrayCompletionBlock)completion NS_DEPRECATED_IOS(7.0, 7.0);
|
||||
|
||||
/**
|
||||
* Lists all persons inside a person group
|
||||
* @param personGroupId the person group id
|
||||
* @param completion completion handler
|
||||
* @return the persons, NSArray containing MPOPerson objects
|
||||
*/
|
||||
- (NSURLSessionDataTask *)listPersonsWithPersonGroupId:(NSString *)personGroupId completionBlock:(MPOPersonArrayCompletionBlock)completion;
|
||||
|
||||
|
||||
/**
|
||||
* Gets a face of a person
|
||||
|
|
|
@ -159,11 +159,29 @@ typedef void(^PORequestCompletionBlock)(NSURLResponse *response, id responseObje
|
|||
}];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)verifyWithFirstFaceId:(NSString *)faceId personId:(NSString *)personId completionBlock:(void (^) (MPOVerifyResult *verifyResult, NSError *error))completion {
|
||||
|
||||
return [self startTaskWithHttpMethod:@"POST" path:@"verify" parameters:@{@"faceId" : faceId, @"personId" : personId} urlParams:nil bodyData:nil completion:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
|
||||
MPOVerifyResult *verifyResult = nil;
|
||||
|
||||
if (!error && [responseObject isKindOfClass:[NSDictionary class]]) {
|
||||
verifyResult = [[MPOVerifyResult alloc] initWithDictionary:responseObject];
|
||||
}
|
||||
|
||||
[self runCompletionOnMainQueueWithBlock:completion object:verifyResult error:error];
|
||||
}];
|
||||
}
|
||||
|
||||
//return IdentifyResult[]
|
||||
- (NSURLSessionDataTask *)identifyWithPersonGroupId:(NSString *)personGroupId faceIds:(NSArray *)faceIds maxNumberOfCandidates:(NSInteger)maxNumberOfCandidates completionBlock:(MPOIdentifyResultArrayCompletionBlock)completion {
|
||||
|
||||
return [self startTaskWithHttpMethod:@"POST" path:@"identify" parameters:@{@"faceIds" : faceIds, @"personGroupId" : personGroupId, @"maxNumOfCandidatesReturned" : [NSNumber numberWithInteger:maxNumberOfCandidates]} urlParams:nil bodyData:nil completion:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
return [self identifyWithPersonGroupId:personGroupId faceIds:faceIds maxNumberOfCandidates:maxNumberOfCandidates confidenceThreshold:0.7 completionBlock:completion];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)identifyWithPersonGroupId:(NSString *)personGroupId faceIds:(NSArray *)faceIds maxNumberOfCandidates:(NSInteger)maxNumberOfCandidates confidenceThreshold:(CGFloat)confidenceThreshold completionBlock:(MPOIdentifyResultArrayCompletionBlock)completion {
|
||||
|
||||
return [self startTaskWithHttpMethod:@"POST" path:@"identify" parameters:@{@"faceIds" : faceIds, @"personGroupId" : personGroupId, @"maxNumOfCandidatesReturned" : [NSNumber numberWithInteger:maxNumberOfCandidates], @"confidenceThreshold":[NSNumber numberWithFloat:confidenceThreshold]} urlParams:nil bodyData:nil completion:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
|
||||
NSMutableArray *identifyResults = [[NSMutableArray alloc] init];
|
||||
|
||||
|
@ -179,20 +197,36 @@ typedef void(^PORequestCompletionBlock)(NSURLResponse *response, id responseObje
|
|||
}];
|
||||
}
|
||||
|
||||
|
||||
//return SimilarFace[]
|
||||
- (NSURLSessionDataTask *)findSimilarWithFaceId:(NSString *)faceId faceIds:(NSArray *)faceIds completionBlock:(MPOSimilarFaceArrayCompletionBlock)completion {
|
||||
|
||||
return [self findSimilarWithFaceId:faceId faceListId:nil faceIds:faceIds maxNumOfCandidatesReturned:20 mode:@"matchPerson" completionBlock:completion];
|
||||
}
|
||||
|
||||
return [self startTaskWithHttpMethod:@"POST" path:@"findsimilars" parameters:@{@"faceId" : faceId, @"faceIds" : faceIds} urlParams:nil bodyData:nil completion:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
- (NSURLSessionDataTask *)findSimilarWithFaceId:(NSString *)faceId faceListId:(NSString *)faceListId completionBlock:(MPOSimilarFaceArrayCompletionBlock)completion {
|
||||
|
||||
return [self findSimilarWithFaceId:faceId faceListId:faceListId faceIds:nil maxNumOfCandidatesReturned:20 mode:@"matchPerson" completionBlock:completion];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)findSimilarWithFaceId:(NSString *)faceId faceListId:(NSString *)faceListId faceIds:(NSArray *)faceIds maxNumOfCandidatesReturned:(NSInteger)maxNumOfCandidatesReturned mode:(MPOSimilarFaceSearchingMode)mode completionBlock:(MPOSimilarFaceArrayCompletionBlock)completion {
|
||||
NSDictionary * param = nil;
|
||||
NSString * modeString = (mode == MPOSimilarFaceSearchingModeMatchPerson) ? @"matchPerson" : @"matchFace";
|
||||
if (faceListId) {
|
||||
param = @{@"faceId" : faceId, @"faceListId" : faceListId, @"maxNumOfCandidatesReturned" : @(maxNumOfCandidatesReturned), @"mode" : modeString};
|
||||
} else {
|
||||
param = @{@"faceId" : faceId, @"faceIds" : faceIds, @"maxNumOfCandidatesReturned" : @(maxNumOfCandidatesReturned), @"mode" : modeString};
|
||||
}
|
||||
return [self startTaskWithHttpMethod:@"POST" path:@"findsimilars" parameters:param urlParams:nil bodyData:nil completion:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
|
||||
NSMutableArray *similarFaces = [[NSMutableArray alloc] init];
|
||||
|
||||
|
||||
if (!error) {
|
||||
for (id faceObj in responseObject) {
|
||||
NSString *faceId = faceObj[@"faceId"];
|
||||
|
||||
NSString *confidence = faceObj[@"confidence"];
|
||||
MPOSimilarFace *similarFace = [[MPOSimilarFace alloc] init];
|
||||
similarFace.faceId = faceId;
|
||||
similarFace.confidence = confidence;
|
||||
[similarFaces addObject:similarFace];
|
||||
}
|
||||
}
|
||||
|
@ -201,6 +235,15 @@ typedef void(^PORequestCompletionBlock)(NSURLResponse *response, id responseObje
|
|||
}];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)findSimilarWithFaceId:(NSString *)faceId faceIds:(NSArray *)faceIds maxNumOfCandidatesReturned:(NSInteger)maxNumOfCandidatesReturned mode:(MPOSimilarFaceSearchingMode)mode completionBlock:(MPOSimilarFaceArrayCompletionBlock)completion {
|
||||
return [self findSimilarWithFaceId:faceId faceListId:nil faceIds:faceIds maxNumOfCandidatesReturned:20 mode:mode completionBlock:completion];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)findSimilarWithFaceId:(NSString *)faceId faceListId:(NSString *)faceListId maxNumOfCandidatesReturned:(NSInteger)maxNumOfCandidatesReturned mode:(MPOSimilarFaceSearchingMode)mode completionBlock:(MPOSimilarFaceArrayCompletionBlock)completion {
|
||||
return [self findSimilarWithFaceId:faceId faceListId:faceListId faceIds:nil maxNumOfCandidatesReturned:20 mode:mode completionBlock:completion];
|
||||
}
|
||||
|
||||
|
||||
//return GroupResult
|
||||
- (NSURLSessionDataTask *)groupWithFaceIds:(NSArray *)faceIds completionBlock:(void (^) (MPOGroupResult *groupResult, NSError *error))completion {
|
||||
return [self startTaskWithHttpMethod:@"POST" path:@"group" parameters:@{@"faceIds" : faceIds} urlParams:nil bodyData:nil completion:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
|
@ -262,10 +305,25 @@ typedef void(^PORequestCompletionBlock)(NSURLResponse *response, id responseObje
|
|||
}
|
||||
|
||||
- (NSURLSessionDataTask *)getPersonGroupsWithCompletion:(MPOPersonGroupArrayCompletionBlock)completion {
|
||||
return [self startTaskWithHttpMethod:@"GET" path:@"persongroups" parameters:nil urlParams:nil bodyData:nil completion:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
|
||||
return [self listPersonGroupsWithStart:nil top:1000 completionBlock:completion];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)listPersonGroupsWithCompletion:(MPOPersonGroupArrayCompletionBlock)completion {
|
||||
|
||||
return [self listPersonGroupsWithStart:nil top:1000 completionBlock:completion];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)listPersonGroupsWithStart:(NSString*)start top:(NSInteger)top completionBlock:(MPOPersonGroupArrayCompletionBlock)completion {
|
||||
top = MAX(1000, top);
|
||||
NSString * url = [NSString stringWithFormat:@"persongroups?top=%d", top];
|
||||
if (start != nil) {
|
||||
url = [url stringByAppendingString:[NSString stringWithFormat:@"&start=%@", start]];
|
||||
}
|
||||
return [self startTaskWithHttpMethod:@"GET" path:url parameters:nil urlParams:nil bodyData:nil completion:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
|
||||
NSMutableArray *responseCollection = [[NSMutableArray alloc] init];
|
||||
|
||||
|
||||
if (!error) {
|
||||
for (id obj in responseObject) {
|
||||
MPOPersonGroup *personGroup = [[MPOPersonGroup alloc] initWithDictionary:obj];
|
||||
|
@ -300,7 +358,6 @@ typedef void(^PORequestCompletionBlock)(NSURLResponse *response, id responseObje
|
|||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark Person
|
||||
/*
|
||||
* =============================================================
|
||||
|
@ -357,8 +414,14 @@ typedef void(^PORequestCompletionBlock)(NSURLResponse *response, id responseObje
|
|||
|
||||
- (NSURLSessionDataTask *)getPersonsWithPersonGroupId:(NSString *)personGroupId completionBlock:(MPOPersonArrayCompletionBlock)completion {
|
||||
|
||||
return [self listPersonsWithPersonGroupId:personGroupId completionBlock:completion];
|
||||
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)listPersonsWithPersonGroupId:(NSString *)personGroupId completionBlock:(MPOPersonArrayCompletionBlock)completion {
|
||||
|
||||
return [self startTaskWithHttpMethod:@"GET" path:[NSString stringWithFormat:@"persongroups/%@/persons", personGroupId] parameters:nil urlParams:nil bodyData:nil completion:^(NSURLResponse *response, id responseObject, NSError *error) {
|
||||
|
||||
|
||||
NSMutableArray *personCollection = [[NSMutableArray alloc] init];
|
||||
|
||||
if (!error) {
|
||||
|
|
|
@ -32,5 +32,6 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface MPOSimilarFace : NSObject
|
||||
@property NSString *faceId;
|
||||
@property (nonatomic, retain) NSString *faceId;
|
||||
@property (nonatomic, retain) NSNumber *confidence;
|
||||
@end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = "ProjectOxfordFace"
|
||||
s.version = "1.0"
|
||||
s.version = "1.1"
|
||||
s.summary = "Microsoft Project Oxford Face iOS SDK"
|
||||
|
||||
s.description = <<-DESC
|
||||
|
@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|||
s.license = 'MIT'
|
||||
s.author = { "Project Oxford SDK" => "oxfordGithub@microsoft.com" }
|
||||
s.source = { :git => "https://github.com/Microsoft/Cognitive-Face-iOS.git", :branch => "master" }
|
||||
s.platform = :ios, '9.0'
|
||||
s.platform = :ios, '8.0'
|
||||
s.requires_arc = true
|
||||
|
||||
s.source_files = 'Pod/Classes/**/*'
|
||||
|
|
Загрузка…
Ссылка в новой задаче