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.
- SDK.check_spoof_image_face_size(self: tfsdk.SDK, face_box_and_landmarks: tfsdk.FaceBoxAndLandmarks, image_properties: tfsdk.ImageProperties, active_spoof_state: tfsdk.ACTIVESPOOFSTAGE) → tfsdk.ERRORCODE¶
Ensures that the face size meets the requirements for active spoof. Must check function return value! 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
tfsdk.SDK.detect_active_spoof()
.- Parameters
face_box_and_landmarks - The face on which to run active spoof detection.
image_properties - The properties of the image, obtained from
tfsdk.SDK.get_image_properties()
.active_spoof_state - The stage of the image, either near stage or far stage.
- Returns
The
ERRORCODE
. IfERRORCODE.NO_ERROR
is returned, then the image is eligible for active spoof detection. IfERRORCODE.FACE_TOO_CLOSE
orERRORCODE.FACE_TOO_FAR
is returned, the image is not eligible for active spoof detection.
- SDK.detect_active_spoof(self: tfsdk.SDK, near_face_landmarks: List[tfsdk.Point[106]], far_face_landmarks: List[tfsdk.Point[106]]) → Tuple[tfsdk.ERRORCODE, float, tfsdk.SPOOFLABEL]¶
Detect if there is a presentation attack attempt. Must call
tfsdk.SDK.check_spoof_image_size()
on both input faces before calling this function.- Parameters
near_face_landmarks - The face landmarks of the near face, obtained by calling
tfsdk.SDK.get_face_landmarks()
.far_face_landmarks - The face landmarks of the far face, obtained by calling
tfsdk.SDK.get_face_landmarks()
.
- Returns
The
ERRORCODE
, the spoof score, and thetfsdk.SPOOFLABEL
, in that order.
- class tfsdk.ACTIVESPOOFSTAGE¶
Members:
NEAR : Near image
FAR : Far image
- class tfsdk.SPOOFLABEL¶
Members:
FAKE : The image may be an attempted spoof
REAL : The face image is real
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.
- SDK.detect_spoof(self: tfsdk.SDK, face_box_and_landmarks: tfsdk.FaceBoxAndLandmarks, threshold: float = 0.5) → Tuple[tfsdk.ERRORCODE, tfsdk.SPOOFLABEL, float]¶
Detect if there is a spoof attempt. Returns the spoof score.
- Parameters
face_box_and_landmarks –
tfsdk.FaceBoxAndLandmarks
returned bytfsdk.SDK.detect_faces()
ortfsdk.SDK.detect_largest_face()
.threshold – the spoof score threshold above which it is considered a spoof attempt (default = 0.5).
- Returns
The
ERRORCODE
, thetfsdk.SPOOFLABEL
, and the spoof score, in that order.