justadudewhohacks / face-api.js

JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js
MIT License
16.57k stars 3.69k forks source link

how to detect fake face? #636

Open khansikki opened 4 years ago

khansikki commented 4 years ago

awesome work !!!

  1. but how to do some stuff only on detections, as it was defined on setInterval, like showing capture button etc., may cause loop effect and

  2. how to check the realness of video ? is it possible to do eye blink detection and mobile screen detection

please assist :)

balapkm commented 4 years ago

Is there any solution for this ?

khansikki commented 4 years ago

display button part is easy, instead of creating we can pre-create before interval and display is using if condition like this

let video = $(this)[0]; const canvas = faceapi.createCanvasFromMedia(video) const displaySize = {width:video.videoWidth,height:video.videoHeight} faceapi.matchDimensions(canvas,displaySize) $(canvas).appendTo("#camera .row:first-child") let detections; let loop = setInterval(async()=>{ detections = await faceapi.detectAllFaces(video,new faceapi.TinyFaceDetectorOptions()).withFaceLandmarks() const resizedDetections = faceapi.resizeResults(detections,displaySize) canvas.getContext('2d').drawImage(video,0,0) //faceapi.draw.drawDetections(canvas,resizedDetections) faceapi.draw.drawFaceLandmarks(canvas,resizedDetections) if(detections.length>0){ $("#capt").show(); console.log("face detected") }else{ $("#capt").hide(); } },108)

but don't know how to identify fake face, can we detect eye blink with facelandmark 68 model ? if so we can win over the 2d face faking

found this article is it possible to implement in face-api.js https://medium.com/swlh/anti-spoofing-mechanisms-in-face-recognition-based-on-dnn-586011ccc416