Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Face Detection with error code 0 #50

Open
jatin-lakhani opened this issue Oct 10, 2018 · 3 comments
Open

Face Detection with error code 0 #50

jatin-lakhani opened this issue Oct 10, 2018 · 3 comments

Comments

@jatin-lakhani
Copy link

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

@lebronJ
Copy link

lebronJ commented Oct 31, 2018

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

@jatin-lakhani
Copy link
Author

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

1 similar comment
@jatin-lakhani
Copy link
Author

jatin-lakhani commented Oct 31, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants