I’m working on a project that uses facial tracking on live video feeds. I want to set up a loop so that when there is no face detected, a ~20 second clip of the last recognized face is played. Does anyone know how to do this?
Hi @sunjocelyn,
Welcome to the community!
We can record video of a tracked face in 2 ways:
- use a Cache TOP to save n seconds of video
- use the Movie File Out TOP to save the camera feed
Theoretically we could use a Cache TOP to record a 20 second window of a tracked face - but that might require a lot of graphics memory - each frame of a HD video takes up about 9 MB of video card memory, with each second having by default 60 frames, we end up with 540 MB per second - so 20 seconds would result in 10GB of required memory - save to say that this is not an option.
So we have use the Movie File Out TOP to record the video. As we cannot have a rolling recording window, you would just have to enable the Record
parameter right when the person starts being detected and turn off the parameter right when the person steps out of the frame.
A practical consideration might be to give it a bit of extra time in case the tracking fails for a split second - that should not necessarily end the recording… Maybe if there is no person detected for 1 second, the recording should be stopped.
So next you would have to build a logic where once the tracked face disappears:
- first the recording is being turned off
- second a Movie File In TOP start playing the recorded video.
In total the flow would be:
- play video while there is no face being tracked (make sure you have a default video for while before the first person steps into the frame)
- when face is being tracked, turn off the playback and start recording
- when face leaves the frame, turn off recording and start playback
Do you already know how you will track the face?
cheers
Markus
Hi Markus,
Thank you for the detailed explanation! I’m currently tracking the face using the facetrack TOP. I have a live video feed that I want to play as default. The recorded faces would be played when there are no faces in frame. I’ll try a solution based on your suggested workflow and update you.
Best,
Jocelyn