我正在做一个捕获照片以验证用户的 android 应用程序。我正在尝试使用少量图像创建 personGroup。但我得到了这个错误。
com.microsoft.projectoxford.face.rest.ClientException:人员组 ID 无效。
我的代码是,
public fun createPersonGroup(personGroupId: String, personGroupName: String) {
faceServiceClient.createPersonGroup(personGroupId, personGroupName, null)
}
public fun addPersonToGroup(personGroupId: String, name: String, pathToImages: File) {
val person = faceServiceClient.createPerson(personGroupId, name, null)
detectAndRegister(personGroupId, person, pathToImages)
}
private fun detectAndRegister(personGroupId: String, person: CreatePersonResult?, pathToImages: File) {
for (file in pathToImages.listFiles()) {
val stream = file.inputStream()
faceServiceClient.addPersonFace(personGroupId, person!!.personId, stream, null, null)
}
trainingAI(personGroupId)
}
private fun trainingAI(personGroupId: String) {
faceServiceClient.trainPersonGroup(personGroupId)
var trainingStatus: TrainingStatus? = null
while (true) {
trainingStatus = faceServiceClient.getPersonGroupTrainingStatus(personGroupId)
if (trainingStatus!!.status != TrainingStatus.Status.Running) {
runOnUiThread { progressDialog.dismiss() }
break
}
}
}