POST /videolivedetection
Performs a face liveness detection (see Face Liveness Detection) on the attached video.
The liveness detection on videos is a straightforward procedure: we start with the first frame of the video, try to detect a suitable face in this frame and perform a standard live detection on the facial image. We repeat the procedure for frames with some offset (~300 millisecond) in the video until a break condition is reached. A final decision is made on the number of live images vs fake images vs failed suitable face detections.
Please ensure that the uploaded video is not too big. A video of about three seconds length should be enough.
App-ID
:App-Secret
. To receive the necessary BWS WebAPI access data
(App-ID
and App-Secret
) you have to register your application on the
BWS Portal first. This requires a valid BWS subscription.
state
parameter can be provided which is simply passed through to the BWS log and to the returned object.
The video is simply attached to the POST using a multipart/form-data body content.
The video liveness detection API returns a LiveDetectionResult
object, that primarily contains the flag Success,
which indicates, whether the live detection succeeded or not:
Success
FailedToAcquire
JobID
State
In case something goes wrong, an error HTTP status code is returned together with some additional information if available.
The call returns one of the standard HTTP status codes. With the success code (200) you receive
the described LiveDetectionResult
object in the body text. With erroneous codes you typically get
a Message field within the body text describing the error. The most commonly returned codes are:
LiveDetectionResult
object.
No or more than one streams have been submitted. The response body typically has
a Message
field containing the error code:
Message
and an ExceptionMessage
.
private static async Task<bool> VideoLiveDetectionAsync(Stream videoStream)
{
using (var client = new HttpClient())
using (var streamContent = new StreamContent(videoStream))
using (var content = new MultipartFormDataContent())
{
content.Add(streamContent);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "...");
using (var response = await httpClient.PostAsync("https://bws.bioid.com/extension/videolivedetection", content);
{
if (response.StatusCode == HttpStatusCode.OK)
{
string result = await response.Content.ReadAsStringAsync();
Console.Write("Result: " + result);
var json = JObject.Parse(result);
bool success = (bool)json["Success"];
bool fta = (bool)json["FailedToAcquire"];
...
return success;
}
Console.WriteLine(response.StatusCode.ToString());
return false;
}
}
}