Spoof Detection

Active Spoof

Active spoof requires many steps and is an involved process. Therefore, please be sure to consult the sample code which comes shipped as part of the SDK bundle for a demonstration of proper usage.

ErrorCode Trueface::SDK::checkSpoofImageFaceSize(const FaceBoxAndLandmarks &faceBoxAndLandmarks, ImageProperties imageProperties, ActiveSpoofStage activeSpoofStage)

Ensures that the face size meets the requirements for active spoof. Must check return value of function! Active spoof works by analyzing the way a persons face changes as they move closer to a camera. The active spoof solution therefore expects the face a certain distance from the camera. In the far image, the face should be about 18 inches from the camera, while in the near image, the face should be 7-8 inches from the camera. This function must be called before calling detectActiveSpoof().

Parameters
  • faceBoxAndLandmarks – The face on which to run active spoof detection.

  • imageProperties – The properties of the image, obtained from getImageProperties().

  • activeSpoofStage – The stage of the image, either near stage or far stage.

Returns

error code, see ErrorCode. If ErrorCode::NO_ERROR is returned, then the image is eligible for active spoof detection. If ErrorCode::FACE_TOO_CLOSE or ErrorCode::FACE_TOO_FAR is returned, the image is not eligible for active spoof detection.

ErrorCode Trueface::SDK::detectActiveSpoof(const Landmarks &nearFaceLandmarks, const Landmarks &farFaceLandmarks, float &spoofScore, SpoofLabel &spoofPrediction)

Detect if there is a presentation attack attempt. Must call checkSpoofImageFaceSize() on both input faces before calling this function.

Parameters
  • nearFaceLandmarks – The face landmarks of the near face, obtained by calling getFaceLandmarks().

  • farFaceLandmarks – The face landmarks of the far face, obtained by calling getFaceLandmarks().

  • spoofScore – The output spoof score. If the spoof score is above the threshold, then it is classified as a real face. If the spoof score is below the threshold, then it is classified as a fake face.

  • spoofPrediction – The predicted spoof result, using a spoofScore threshold of 1.05.

Returns

error code, see ErrorCode.

enum Trueface::ActiveSpoofStage

Active spoof involves two stages: a near image and a far image. The following enum is used to track which stage image is being analyzed.

Values:

enumerator NEAR

Near image.

enumerator FAR

Far image.

enum Trueface::SpoofLabel

Results from spoof detection

Values:

enumerator REAL

The face image is real

enumerator FAKE

The image may be an attempted spoof

Passive Spoof

Warning

We are finding some limitations with a passive approach to spoof detection. Until we have an improved model we will mark this API method as deprecated. We will continue to support this implementation but want to make you aware that there will be an updated solution with different requirements.

Deprecated since version 0.17.

ErrorCode Trueface::SDK::detectSpoof(const FaceBoxAndLandmarks &faceBoxAndLandmarks, SpoofLabel &result, float &spoofScore, float threshold = 0.5)

Detect if there is a presentation attack attempt.

Parameters
  • faceBoxAndLandmarks[in] FaceBoxAndLandmarks returned by detectFaces() or detectLargestFace().

  • result[out] the SpoofLabel results for the face image.

  • spoofScore[out] the probability that the image is a spoof attempt (1 indicates real image, 0 indicates spoof attempt).

  • threshold[out] the spoof score threshold above which it is considered a spoof attempt.

Returns

error code, see ErrorCode.