Cognitive-Face-iOS
Cognitive-Face-iOS copied to clipboard
Face Detection with error code 0
Hey,
We're using your Face detection and Face verification APIs form the SDK and we've also paid for the service still I'm getting one unknown error in the detection api. Here I'm attaching screenshot for the error.
Could you please provide the solution for this error?
Thank you!
Is this fixed by any chance? If not, Can you show some code snippets so that we can better diagnose this issue? Thanks.
func get_faceId(img:UIImage) { if(CommonFunction.isInternetAvailable()) { self.lblStatusapi.text = "Face ID API Processing" MBProgressHUD.showAdded(to: self.view, animated: true) var faceid_str = NSString() let data = UIImageJPEGRepresentation(img, 0.3) let client = MPOFaceServiceClient(endpointAndSubscriptionKey: "https://westcentralus.api.cognitive.microsoft.com/face/v1.0", key: "879514a5b3ad482b976cd6ed9eb517bc") client?.detect(with: data, returnFaceId: true, returnFaceLandmarks: true, returnFaceAttributes: [], completionBlock: { (collection, error) in MBProgressHUD.hide(for: self.view, animated: true) if(error == nil) { self.lblStatusapi.text = "Face ID API Success" if (collection?.count == 0) { if(self.current_selection=="Passport") { self.imageview_passport.image = nil self.imageview_passport.isHidden = true self.btn_passport.isHidden = false } else { self.imageview_photo.image = nil self.imageview_photo.isHidden = true self.btn_photo.isHidden = false } self.displayAlert(msg: "No face detected", title_str: Constants.APP_NAME) } else { self.displayAlert(msg: "Face detected successfully", title_str: Constants.APP_NAME) if let faceid_str = collection![0].faceId as NSString? { if(self.current_selection=="Passport") { self.imageview_passport.isHidden = false self.passport_faceId = faceid_str self.imageview_passport.image = self.passport_image self.passport_img_btn.isHidden = false self.btn_passport.isHidden = true } else { self.imageview_photo.isHidden = false self.photo_faceId = faceid_str self.imageview_photo.image = self.photo_image self.photo_img_btn.isHidden = false self.btn_photo.isHidden = true } } } } else { self.lblStatusapi.text = "Face ID API Fail" if(self.current_selection=="Passport") { self.imageview_passport.image = nil self.imageview_passport.isHidden = true self.btn_passport.isHidden = false } else { self.imageview_photo.image = nil self.imageview_photo.isHidden = true self.btn_photo.isHidden = false } self.displayAlert(msg: "Something went wrong. Please try again", title_str: Constants.APP_NAME) } }) } else { self.displayAlert(msg: "Please Check Your Internet Connection!!", title_str: Constants.APP_NAME) } }
func get_faceId(img:UIImage) { if(CommonFunction.isInternetAvailable()) { self.lblStatusapi.text = "Face ID API Processing" MBProgressHUD.showAdded(to: self.view, animated: true) var faceid_str = NSString() let data = UIImageJPEGRepresentation(img, 0.3) let client = MPOFaceServiceClient(endpointAndSubscriptionKey: "https://westcentralus.api.cognitive.microsoft.com/face/v1.0", key: "879514a5b3ad482b976cd6ed9eb517bc") client?.detect(with: data, returnFaceId: true, returnFaceLandmarks: true, returnFaceAttributes: [], completionBlock: { (collection, error) in MBProgressHUD.hide(for: self.view, animated: true) if(error == nil) { self.lblStatusapi.text = "Face ID API Success" if (collection?.count == 0) { if(self.current_selection=="Passport") { self.imageview_passport.image = nil self.imageview_passport.isHidden = true self.btn_passport.isHidden = false } else { self.imageview_photo.image = nil self.imageview_photo.isHidden = true self.btn_photo.isHidden = false } self.displayAlert(msg: "No face detected", title_str: Constants.APP_NAME) } else { self.displayAlert(msg: "Face detected successfully", title_str: Constants.APP_NAME) if let faceid_str = collection![0].faceId as NSString? { if(self.current_selection=="Passport") { self.imageview_passport.isHidden = false self.passport_faceId = faceid_str self.imageview_passport.image = self.passport_image self.passport_img_btn.isHidden = false self.btn_passport.isHidden = true } else { self.imageview_photo.isHidden = false self.photo_faceId = faceid_str self.imageview_photo.image = self.photo_image self.photo_img_btn.isHidden = false self.btn_photo.isHidden = true } } } } else { self.lblStatusapi.text = "Face ID API Fail" if(self.current_selection=="Passport") { self.imageview_passport.image = nil self.imageview_passport.isHidden = true self.btn_passport.isHidden = false } else { self.imageview_photo.image = nil self.imageview_photo.isHidden = true self.btn_photo.isHidden = false } self.displayAlert(msg: "Something went wrong. Please try again", title_str: Constants.APP_NAME) } }) } else { self.displayAlert(msg: "Please Check Your Internet Connection!!", title_str: Constants.APP_NAME) } }