POST /qualitycheck?full=true&issuer=ICAO
With the quality check Web API a single facial media sample can be uploaded to the BWS to perform a rigorous quality check according to ICAO (International Civil Aviation Organization) requirements for machine readable travel documents (MRTDs), which include a standard for the digital image quality of facial images, defining requirements for photographic and digital characteristics (see ISO/IEC 19794-5:2011, ISO/IEC 29794-5:2010 or ICAO Document 9303).
Quality checks for traits other than face are currently not supported with this API.
The quality checks performed with this method are descried with the SOAP Quality Check API.
true
. A boolean parameter to select full document mode or token data mode.
If set to true
, the checks are performed according to the ICAO specifications for travel documents and
an output sample is created according to these specifications, whereby the content of the sample is not modified.
Otherwise, if set to false
, the so called token data is extracted from the given sample,
which is typically intended to be stored for later use with a biometric recognition system.
The request body contains a single image media sample, encoded into a Data-URL using the data URI scheme as described in RFC 2397 (see also at Wikipedia).
The QualityCheck Web API returns a QualityCheckResult
object, which informs about the Success of the check and lists Errors
that occurred during the check. Refer to the SOAP Quality Check API for a list of possible error-codes.
Additionally the coordinates of the found EyeCenters are returned. Finally the processed image is returned
in the ProcessedSample element if possible, encoded into a Data-URL.
{
"Success": true,
"Errors": [
{
"Code": "ImageTooSmall",
"Message": "The part of the image containing the found face is too small.",
"Details": "The found face (with an eye-distance of 119 pixels) does not have the required eye-distance of at least 240 pixels."
},
{
"Code": "FaceAsymmetry",
"Message": "It seems that the face of the found person is somehow asymmetric, maybe due to bad illumination and/or due to a wrong pose.",
"Details": "An asymmetry of 101.99 was calculated, where only a value up to 50.00 is allowed."
},
{
"Code": "ImageTooBlurry",
"Message": "The image is too blurry, i.e. it is not sharp enough.",
"Details": "An image blurring of 10.45% was calculated, where up to 9.00% is allowed. Note that compression artifacts might be the reason for this fuzziness as they reduce the objective sharpness more than the subjective sharpness."
}
],
"EyeCenters":
{
"RightEyeX": 828.401, "RightEyeY": 584.267, "LeftEyeX": 947.88, "LeftEyeY": 587.003
},
"ProcessedSample": "data:image/bmp;base64,..."
}
The call returns one of the standard HTTP status codes. With the success code (200) you receive the QualityCheckResult
object in the body text. With erroneous codes you typically receive a Message field within the body text describing the error.
The most commonly return codes are:
QualityCheckResult
object.
No or an invalid sample data has been uploaded.
private static async Task<string> QualityCheckAsync(bool full, string issuer, string dataUrlImage)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($"{APP_IDENTIFIER}:{APP_SECRET}")));
using (var content = new StringContent(dataUrlImage))
using (var response = await client.PostAsync(ENDPOINT + $"qualitycheck?full={full}&issuer={issuer}", content))
{
Console.Write("QualityCheck Response... ");
if (response.StatusCode == HttpStatusCode.OK)
{
string result = await response.Content.ReadAsStringAsync();
var json = JObject.Parse(result);
bool success = (bool)json["Success"];
var errors = json["Errors"];
var eyeCenters = json["EyeCenters"];
string base64ProcessSample = (string)json["ProcessedSample"];
Console.WriteLine(success);
return json.ToString();
}
Console.WriteLine(response.StatusCode.ToString());
return string.Empty;
}
}
}
// using OkHttpClient from the OkHttp library
HttpUrl url = HttpUrl.parse("https://bws.bioid.com/extension/qualitycheck").newBuilder()
.addQueryParameter("full", "true")
.addQueryParameter("issuer", "ICAO")
.build();
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization", Credentials.basic(APP_IDENTIFIER, APP_SECRET))
.post(RequestBody.create(MediaType.parse("text/plain"), "data:image/png;base64," + Base64.getEncoder().encodeToString(getPngAsByteArray())))
.build();
OkHttpClient client = new OkHttpClient();
Response response = client.newCall(request).execute();
if (response.code() == 200) {
// using org.json.JSONObject from JSON-java library
JSONObject json = new JSONObject(response.body().string());
if (json.getBoolean("Success")) {
System.out.println("quality check has been performed");
} else {
System.out.println("quality check was not possible");
}
}