Skip to content

Commit 9dc8eb5

Browse files
committed
Add Group method to Face resource
1 parent 9e3f2d7 commit 9dc8eb5

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

src/Resources/Face.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,22 @@ public function findSimilarInFaceIdsArray(string $faceId, array $faceIds, int $m
174174
])
175175
);
176176
}
177+
178+
/**
179+
* Divide candidate faces into groups based on face similarity.
180+
*
181+
* @param array $faceIds Array of candidate faceId created by Face - Detect
182+
* @return array
183+
* @throws \GuzzleHttp\Exception\GuzzleException
184+
*/
185+
public function group(array $faceIds): array
186+
{
187+
return $this->decodeJsonResponse(
188+
$this->httpClient->post('group', [
189+
'json' => [
190+
'faceIds' => $faceIds
191+
]
192+
])
193+
);
194+
}
177195
}

tests/Resources/FaceTest.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function testFindSimilarInLargeFaceListWithDefaultParameters()
122122
'largeFaceListId' => 'any_large_face_list_id',
123123
'maxNumOfCandidatesReturned' => 20,
124124
'mode' => 'matchPerson',
125-
])
125+
], true)
126126
->willRespond($this->emptyJsonResponse());
127127

128128
$this->sut->findSimilarInLargeFaceList('any_face_id', 'any_large_face_list_id');
@@ -139,7 +139,7 @@ public function testFindSimilarInLargeFaceList()
139139
'largeFaceListId' => 'any_large_face_list_id',
140140
'maxNumOfCandidatesReturned' => 10,
141141
'mode' => 'matchFace',
142-
])
142+
], true)
143143
->willRespond($this->emptyJsonResponse());
144144

145145
$this->sut->findSimilarInLargeFaceList('any_face_id', 'any_large_face_list_id', 10, 'matchFace');
@@ -156,7 +156,7 @@ public function testFindSimilarInFaceListWithDefaultParameters()
156156
'faceListId' => 'any_face_list_id',
157157
'maxNumOfCandidatesReturned' => 20,
158158
'mode' => 'matchPerson',
159-
])
159+
], true)
160160
->willRespond($this->emptyJsonResponse());
161161

162162
$this->sut->findSimilarInFaceList('any_face_id', 'any_face_list_id');
@@ -173,7 +173,7 @@ public function testFindSimilarInFaceList()
173173
'faceListId' => 'any_face_list_id',
174174
'maxNumOfCandidatesReturned' => 10,
175175
'mode' => 'matchFace',
176-
])
176+
], true)
177177
->willRespond($this->emptyJsonResponse());
178178

179179
$this->sut->findSimilarInFaceList('any_face_id', 'any_face_list_id', 10, 'matchFace');
@@ -190,7 +190,7 @@ public function testFindSimilarInFaceIdsArrayWithDefaultParameters()
190190
'faceIds' => ['any_face_id1', 'any_face_id2'],
191191
'maxNumOfCandidatesReturned' => 20,
192192
'mode' => 'matchPerson',
193-
])
193+
], true)
194194
->willRespond($this->emptyJsonResponse());
195195

196196
$this->sut->findSimilarInFaceIdsArray('any_face_id', ['any_face_id1', 'any_face_id2']);
@@ -207,9 +207,23 @@ public function testFindSimilarInFaceIdsArray()
207207
'faceIds' => ['any_face_id1', 'any_face_id2'],
208208
'maxNumOfCandidatesReturned' => 10,
209209
'mode' => 'matchFace',
210-
])
210+
], true)
211211
->willRespond($this->emptyJsonResponse());
212212

213213
$this->sut->findSimilarInFaceIdsArray('any_face_id', ['any_face_id1', 'any_face_id2'], 10, 'matchFace');
214214
}
215+
216+
public function testGroup()
217+
{
218+
$this->guzzler
219+
->expects($this->once())
220+
->post('group')
221+
->withHeader('Content-Type', 'application/json')
222+
->withJson([
223+
'faceIds' => ['any_face_id1', 'any_face_id2'],
224+
], true)
225+
->willRespond($this->emptyJsonResponse());
226+
227+
$this->sut->group(['any_face_id1', 'any_face_id2']);
228+
}
215229
}

0 commit comments

Comments
 (0)