Webcam feed on NodeJs environment
See original GitHub issueHi,
I would like to perform live face detection in a nodejs environment but I don’t quiet see how to do that.
Initially, I was capturing frames from my webcam using opencv4nodejs:
cap = new cv.VideoCapture(videoDeviceId);
(...)
_frame = cap.read();
But then I would have to find a way to convert _frame to a Canvas, right ? At least if I’m using a monkey path like this:
const { Canvas, Image, ImageData } = canvas
faceapi.env.monkeyPatch({ Canvas, Image, ImageData })
Do I have other options ? Would it be possible to use a monkey patch with some opencv4nodejs’ elements ?
I saw this line in README.md:
Alternatively you can simply construct your own tensors from image data and pass tensors as inputs to the API.
Okay, but how can I achieve that ? If I look at detectAllFaces’ signature, I can see the following:
detectAllFaces(input: TNetInput, options?: FaceDetectionOptions): DetectAllFacesTask
And if I look further, I can see that TNetInput can be a TNetInputArg, which can be a TResolvedNetInput, which can be a tf.Tensor3D or tf.Tensor4D.
So I would have to retrieve data from _frame and use them to instantiate a tf.Tensor3D ?
Thanks !
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top GitHub Comments
In case someone comes along after me looking for exactly the code needed. As a repo: https://github.com/mamacker/faceme
This the correct mode, using decodeJpeg and most faster