face-api.js | JavaScript API for face detection | Computer Vision library
kandi X-RAY | face-api.js Summary
kandi X-RAY | face-api.js Summary
JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of face-api.js
face-api.js Key Features
face-api.js Examples and Code Snippets
Community Discussions
Trending Discussions on face-api.js
QUESTION
I'm using ReactJs to execute face-api-js
for face recognition. In the console log I'm getting the values but it is not displaying in the live video.
Unhandled Rejection (TypeError): Cannot set property 'innerHTML' of undefined
this is the error I am getting under the function handleVideoOnPlay
I'm new to the react framework it would be great if someone helps me out.
...ANSWER
Answered 2021-May-27 at 05:38Problem:
Cannot set property 'innerHTML' of undefined
Reason: canvasRef.current
becomes undefined
Before continuing, I found one thing, the line
has Ref, it should be
ref
Now,
I guess you should make use of useEffect()
as follows
QUESTION
I've build an javascript function with face-api.js for my react component which will return/console me the width and height of face detector box. I tried console.log in few places it seems working fine till the models(face-recognition-model).
But when I write async function for face detector to detect face and console. It gives me error-
...ANSWER
Answered 2021-May-13 at 12:11You need to change the order of function declaration. You can not call const
variables before they were declared.
QUESTION
I'm running a face detection model via JS in the webcam, it recognises the face and draws the box correctly. How can I then go about saving the detected face only as an image locally to my computer?
Im grateful for any help! Im stuck!
The code (from face-api.js) is as follows:
JavaScript
...ANSWER
Answered 2021-Mar-26 at 19:42You have a canvas. You can save a canvas: How To Save Canvas As An Image With canvas.toDataURL()?
Assuming detections
is an array:
QUESTION
i use @tensorflow/tfjs-node package for face-api.js package to speed up things (as they said ) that is my code :
...ANSWER
Answered 2021-Mar-21 at 08:25As explained in this github issue
The version of face-api.js you are using is not compatible with tfjs 2.0+ or 3.0+, only obsolete 1.x. Why it worked before you added tfjs-node? because face-api.js actually includes bundled version of tfjs-core 1.x. Once you added tfjs-node, it overrode global tf namespace, but its a much newer version and not compatible.
You must install obsolete tfjs-node 1.x OR follow the pointers they give to use a newer port of face-api.js that supports TF 2.0.
QUESTION
Just found out about the awesome face-api.js repo, and I'm having a great time using the face expressions API. Maybe because I was smiling too much (for the testing).
Anyway, In my app, I want to check if the user is smiling but without displaying the camera video on the screen.
For now, I can check if the user is smiling or not with a pretty good accuracy, but the video has to be on my screen.
How can I remove the video from the screen?
Here is the js code:
...ANSWER
Answered 2021-Jan-18 at 20:25I'm here to answer my own question just in case someone needs it in the future.
The obvious answer should be to add a "display: none;" to the video tag. However, this doesn't work somehow.
Instead, I created the element in javascript, appended it to the DOM, and changed its display to "none", and it worked.
Here is the code that made it work:
QUESTION
My name is Gabriel and I'm using face-api.js to apply FaceRecognition on my final essay, on my way to graduate.
With the objective of trying the face-api and understand how it works, I created the following test.js:
...ANSWER
Answered 2020-Nov-24 at 03:41I did post an Issue to github Face-API page, and there I was able to found a solution, so, if anyone would like to see it: https://github.com/justadudewhohacks/face-api.js/issues/729 Thanks for your time!
QUESTION
import React, { useRef, useState, useEffect } from 'react';
import * as faceapi from 'face-api.js';
function App() {
const videoRef = useRef(null);
const canvasRef = useRef(null);
useEffect(() => {
const loadModels = async () => {
try {
const MODEL_URL = '/models'
Promise.all([
faceapi.nets.tinyFaceDetector.loadFromUri(MODEL_URL),
faceapi.nets.faceLandmark68Net.loadFromUri(MODEL_URL),
faceapi.nets.faceRecognitionNet.loadFromUri(MODEL_URL),
faceapi.nets.faceExpressionNet.loadFromUri(MODEL_URL),
]).then(startVideo())
} catch (error) {
console.error(error)
}
}
loadModels();
}, [])
const startVideo = async () => {
try {
let stream = null;
stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
videoRef.current.srcObject = stream;
} catch (error) {
console.error(error)
}
}
const handleVideoOnPlay = () => {
setInterval(async () => {
const detections = await faceapi.
detectAllFaces(videoRef.current, new faceapi.TinyFaceDetectorOptions())
.withFaceLandmarks()
.withFaceExpressions()
}, 100)
}
return (
);
}
export default App;
...ANSWER
Answered 2020-Oct-15 at 23:07The erorr was videoRef.current was null, just need to wrap it in
QUESTION
I'm trying to run this example in the browser
https://justadudewhohacks.github.io/face-api.js/docs/index.html#getting-started-browser
Specifically this code here
...ANSWER
Answered 2020-Aug-28 at 12:56So, the error you were talking about in the question is:
QUESTION
I am trying to render a class component using conditional rendering. The class component has a state value that is by default set to false. In the class, a function called start()
performs some operation and based on the results, it will call a function verifyTheIdentity()
that has setState()
. But I am not able to call the verifyTheIdentity()
from start()
.
ANSWER
Answered 2020-Jun-06 at 18:18First of all, you do not need bind at all, if you use arrow function.
QUESTION
I have this script and he return this error in console SyntaxError: missing ) after argument list but i dont found where is the error in my code.
...ANSWER
Answered 2020-May-26 at 04:45At the end of all your faceapi.nets.
lines inside the big Promise.add
, you end all the lines with just a comma rather than ending with ),
. Since you are calling loadFromUri
, you need to close the function before moving onto the next one.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install face-api.js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page