Cognitive-Face-iOS icon indicating copy to clipboard operation
Cognitive-Face-iOS copied to clipboard

Face Detection with error code 0

Open jatin-lakhani opened this issue 5 years ago • 3 comments

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! 9eb340b2e99113c09f0181b9a8f52fcd460d584cc318ce27dc pimgpsh_fullsize_distr

jatin-lakhani avatar Oct 10 '18 14:10 jatin-lakhani

Is this fixed by any chance? If not, Can you show some code snippets so that we can better diagnose this issue? Thanks.

lebronJ avatar Oct 31 '18 01:10 lebronJ

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) } }

jatin-lakhani avatar Oct 31 '18 10:10 jatin-lakhani

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) } }

jatin-lakhani avatar Oct 31 '18 10:10 jatin-lakhani