jeeliz / jeelizFaceFilter

Javascript/WebGL lightweight face tracking library designed for augmented reality webcam filters. Features : multiple faces detection, rotation, mouth opening. Various integration examples are provided (Three.js, Babylon.js, FaceSwap, Canvas2D, CSS3D...).
https://jeeliz.com
Apache License 2.0
2.71k stars 535 forks source link

Stop tracking but keep Camera on #80

Closed vin-ni closed 5 years ago

vin-ni commented 5 years ago

Is there a way of pausing the tracking but keeping the camera stream running?

xavierjs commented 5 years ago

Yes, it is described here: https://github.com/jeeliz/jeelizFaceFilter#miscellaneous-methods

vin-ni commented 5 years ago

is it reset_inputTexture() ? toggle_pause also stops the video.

I don't know how to check if the analyzing code is running in the background.

xavierjs commented 5 years ago

Ok I see what you mean. There is currently no way to do this because the video texture is refreshed just before the detection. So if you pause the loop you pause the video texture updating too. What is the purpose of this? Is it to free computing resources for the other parts of the application ?

vin-ni commented 5 years ago

Yes, there will be some interim time, where I'm not tracking anything and just display the video stream. I figured it would be good pause the tracking during that time and turn it back on when I go back to tracking.

vin-ni commented 5 years ago

Is there a line that triggers the detection that I could put into a if / else logic?

xavierjs commented 5 years ago

There was a small bug on the library, I correct it and push so please use the next version otherwise it won't work :). You can do what you want be launching:

JEEFACEFILTERAPI.set_scanSettings({nDetectsPerLoop: 0})

It set the number of neural net detection by rendering loop to 0. So the video will keep updating. Then if you want to restart detection and tracking:

JEEFACEFILTERAPI.set_scanSettings({nDetectsPerLoop: -1})

-1 is for adaptative mode: it process as many detections per second as possible (depending on device capabilities, with a maximum of 5 because it is useless to do more).

vin-ni commented 5 years ago

Thank you so much!