Detecting face liveness not working as expected or mentioned in the documentation

0

In your "Detecting Face Liveness" Service documentation you have mentioned that "Amazon Rekognition Face Liveness helps you verify that a user going through facial verification is physically present in front of a camera. It detects spoof attacks presented to a camera or trying to bypass a camera" however it does not detect spoof video as I have integrated this service in one of my project where we are doing automatic Video KYC.

To test the accuracy I recorded a video from my phone and then while recording for Video KYC I placed my phone in front of the laptop camera, it should have detected that this is spoof but it is giving me 99.9 score.

I am very much disappointed with this.

asked 22 days ago119 views
3 Answers
1
Accepted Answer

While Amazon Rekognition Face Liveness is designed to help verify that a user is physically present in front of a camera and detect spoof attacks, including those presented via images or videos, it's not infallible and may not detect all spoof attempts.

Spoof detection algorithms can vary in effectiveness depending on various factors such as the quality of the camera, lighting conditions, facial expressions, and the sophistication of the spoofing techniques used. Additionally, no spoof detection system is foolproof, and there will always be a possibility of false positives or false negatives.

If you're experiencing issues with the accuracy of the service, I would recommend reaching out to AWS support for further assistance. They may be able to provide guidance on optimizing the configuration or offer insights into potential improvements. Additionally, consider providing feedback to AWS about your experience, as they continuously strive to enhance their services based on user feedback and real-world usage scenarios.

profile picture
EXPERT
answered 21 days ago
  • Hey Adeleke, Thanks for your Response. I am looking for the API's which can detect the Spoof Videos. Please provide me with name of Method or API which I can use for spoof detection.

0

Below I am pasting my code to let you know which methods I am using correctly

async function checkLiveness(job) {
    try {
        const { objectKey, bucketName , params} = job.data;
        if (!objectKey) {
            console.log('No video files found in the bucket.')
            return
            // throw new Error('No video files found in the bucket.');
        }
 
        const rekognitionParams = {
            Video: {
                S3Object: {
                    Bucket: bucketName,
                    Name: objectKey
                }
            },
            FaceAttributes: 'ALL',
            JobTag: 'LivenessCheck'
        };
 
        // Start face detection job
        const startResponse = await rekognition.startFaceDetection(rekognitionParams).promise();
        const jobId = startResponse.JobId;
 
        let jobStatus;
        do {
            await new Promise(resolve => setTimeout(resolve, 5000));
            const statusResponse = await rekognition.getFaceDetection({ JobId: jobId }).promise();
            jobStatus = statusResponse.JobStatus;
        } while (jobStatus !== 'SUCCEEDED' && jobStatus !== 'FAILED');
       
        // Retrieve the face detection results
        const faceDetails = await rekognition.getFaceDetection({ JobId: jobId }).promise();
        const livenessScore = faceDetails.Faces.map(item=>item.Face);
        const livenessData = [];
        asyncLoop(livenessScore, (liveObj, next)=>{
            livenessData.push({
                KYC_id: params.kyc_id,
                bounding_box: liveObj.BoundingBox,
                age_range: liveObj.AgeRange,
                smile: liveObj.Smile,
                eyeglasses: liveObj.Eyeglasses,
                sunglasses: liveObj.Sunglasses,
                gender: liveObj.Gender,
                beard: liveObj.Beard,
                mustache: liveObj.Mustache,
                eyesopen: liveObj.EyesOpen,
                mouthopen: liveObj.MouthOpen,
                emotions: liveObj.Emotions,
                landmarks: liveObj.Landmarks,
                pose: liveObj.Pose,
                quality: liveObj.Quality,
                confidence: liveObj.Confidence
              });
             
            next();
        }, async (err)=> {
            if (err) {
                console.log('error inserting liveness records', err);
                return
            }
            await LivenessManager.createLivenessRecordBulk(livenessData);
            console.log('Livesness record successfully inserted')
            await nameVerification(params.kyc_id)
        })
    } catch (error) {
        console.log(`error while permofing liveness check ${error}`)
        // throw new Error('Error performing liveness check: ' + error.message);
    }
};
answered 21 days ago
0

Based on the new question you asked " Please provide me with name of Method or API which I can use for spoof detection" you can use the "DetectFaces" API provided by Amazon Rekognition You can read more about it here in thie AWS Reference document :- https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html . This API detects faces in an image or video and analyzes facial attributes such as whether the face is real or a spoof.

Here's how you can modify your code to use the "DetectFaces" API for spoof detection:

async function checkLiveness(job) {
    try {
        const { objectKey, bucketName, params } = job.data;
        if (!objectKey) {
            console.log('No video files found in the bucket.');
            return;
        }

        const rekognitionParams = {
            Image: {
                S3Object: {
                    Bucket: bucketName,
                    Name: objectKey
                }
            },
            Attributes: ['ALL']
        };

        // Detect faces in the image
        const detectionResponse = await rekognition.detectFaces(rekognitionParams).promise();
        const faceDetails = detectionResponse.FaceDetails;

        // Check if any detected face is real or a spoof
        const livenessData = faceDetails.map(face => ({
            KYC_id: params.kyc_id,
            bounding_box: face.BoundingBox,
            age_range: face.AgeRange,
            smile: face.Smile,
            eyeglasses: face.Eyeglasses,
            sunglasses: face.Sunglasses,
            gender: face.Gender,
            beard: face.Beard,
            mustache: face.Mustache,
            eyesopen: face.EyesOpen,
            mouthopen: face.MouthOpen,
            emotions: face.Emotions,
            landmarks: face.Landmarks,
            pose: face.Pose,
            quality: face.Quality,
            confidence: face.Confidence
        }));

        // Insert liveness records into the database
        await LivenessManager.createLivenessRecordBulk(livenessData);
        console.log('Liveness records successfully inserted');

        // Perform name verification
        await nameVerification(params.kyc_id);
    } catch (error) {
        console.log(`Error performing liveness check: ${error}`);
    }
};

Please note that the detection of spoof faces may not be perfect and may require additional analysis or validation depending on your specific use case

profile picture
EXPERT
answered 19 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions