New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Faster face detection on video stream #659
Comments
@pec-orange
Description
|
@VellalaVineethKumar You can check if your link is correct by opening it in VLC player (File -> play from URL). Alright, after you got your link - you need to copy this example program: https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam_faster.py Check lines 13-14
This is how you get a video stream from webcam. But this does NOT work for IP cameras. There's the function you will need:
Now you can open your camera stream by providing url to rtsp stream as
The rest of the code should be pretty straightforward.
Let's say you have a photo of your friend Steve in "known_faces/steve.png". The code will be as follows:
|
Thanks for your quick response! and i tried to print the return string in the function: my function call in the return function i removed cv2.CAP_GSTREAMER in the retuen statement as i got an error when i ran on my webcam please help! |
@VellalaVineethKumar
Did you test your video stream before attempting face recognition? Via VLC player or simply by disabling image processing in your code (comment out lines 47-86 in the example), like this:
Anyway, to solve the broke image processing issue you can add a try-except block:
By the way, what operating system you are running this on? My example works on Ubuntu 16.04 and uses GStreamer library... |
@pec-orange With a few tweaks to the facerec_from_webcam_faster.py |
@EmpireofKings Thanks, that might be it. I think that my FPS was much lower because I was using fullHD IP camera instead of webcam and jetson TX1 instead of jetson TX2. Also, I found out, that my jetson TX1 had old CUDA version, so image processing acceleration with the graphic card wasn't working properly. Thanks for the reply, I will try it. |
Hello @pec-orange , just want to know how is your result to this attempt? Does nvpmodel make the performance better? And what is your configuration regarding this attempt? Look forward to it, thanks in advance :D |
@idpdka Sorry, but I didn't test it. Regarding the configuration - I'm working with jetson Xavier right now and it is so much faster than TX2! I highly recommend it if your budget allows that kind of stuff. I also tried to run some tests on jetson Nano - and I was able to get a stable 5-10 FPS. Best of luck in your projects! |
Just an additional note: For anyone using Jetson platform, consider changing the above code from omxh264dec to nvv4l2decoder, because "The gst-omx plugin is deprecated in Linux for Tegra (L4T) Release 32.1. |
This might not be an ideal solution as I have variables in the try block which failed initialization :/ . Is there a better way to solve this issue? |
Description
Is there any way to make the face detection part run faster?
I'm running this for my rtsp camera stream and the video is very slow - each frame takes 2 seconds to process.
I managed to accelerate my video stream to 3 FPS by using "cnn" face detection method, by resizing the processing frame by a factor of 0.33 and by moving all the processing function calls into the separate thread.
I measured time it takes to process one frame - and it is somewhere around 350 ms.
But this is done in the separate thread (not the one that handles video display), so I don't understand why does this slow my video so much.
I am running this program on Nvidia Jetson TX1.
What I Did
The text was updated successfully, but these errors were encountered: