BrandonJoffe / home_surveillance

Home surveillance system with facial recognition
1.22k stars 384 forks source link

Too Low FPS for Face Recognition #17

Open vahid-dan opened 7 years ago

vahid-dan commented 7 years ago

Hi;

I stream using MJPG-Streamer at 15FPS and 320x240 on one camera. The network connection is pretty well and CPU and memory usage are around %50. But the camera FPS in the Dashboard is usually around 1 for Face Recognition. The maximum I could achieve was around 4. For Motion Detection, I can get FPS around 25. I have tested it on two machines with 8GB and 4GB of RAM and the situation is similar. Is that normal? Is there any way I can have a better FPS for Face Recognition? I don't need the Alert System and other parts rather than the basic part of adding a couple of cameras and recognizing faces.

Thanks for your time. :-)

Cheers, Vahid

vahid-dan commented 7 years ago

I just realized that the FPS is too low just for "Face Recognition" and "Motion Detection and Face Recognition". For the rest of the applications, FPS is a few times better. Probably it is because of different models used in these applications.

Vahid

BrandonJoffe commented 7 years ago

Hi @vdaneshmand,

you are 100% correct.

Those methods were mainly used more for testing purposes and provide different functionality which will work better in different scenarios. Face Recognition and Tracking as well as motion object segmentation & face recognition are the most accurate and efficient methods to choose.

Your FPS should be much higher especially with a resolution of 320x240. If you go to the Camera.py script - line 49 'CAPTURE_HZ = 30.0'. The CAPTURE_HZ variable attempts to limit the frame rate to a maximum of 30 frames per second (which should be more than enough). You can try increasing this value to around 40, but please note when you have multiple cameras each of their threads will be taking up unnecessary processing power. So you may have to fiddle with that value a little to find the best solution.

I hope that helps, Brandon

vahid-dan commented 7 years ago

Hi @BrandonJoffe;

Thank you for the explanation. I tried your suggested solution on two different machines and it didn't work. I played with CAPTURE_HZ value and I couldn't see any significant difference. Do you have any other idea?

Thanks, Vahid

mathieuduperre commented 7 years ago

are you sure you are "receiving" that much of high FPS? I'll guess so since you seems to imply you can have 25 fps for some use cases.

Do you have enough resources? monitor cpu/ram/ntwk/storage io and check if they are not peaking up when some frames are processed. I have a similar problem but my system seems quite unstable and I use a very small setup for now. i'll beef it up and will report back if things are going much better.

vahid-dan commented 7 years ago

Hi @methodmath;

I am running it on an Intel® Joule™ 570x Developer Kit with 4GB of RAM and a 64 bit quad-core Intel® Atom™ processor at 1.7 GHz with 2.4 GHz burst and 4MB of Cache running a fresh Ubuntu 16.04 OS. It must be powerful enough to handle it. I have also tried that on my laptop which is much more powerful and the results were almost the same. The face recognition seems too slow.

Thanks, Vahid

vahid-dan commented 7 years ago

Using docker and the last Video Processing Application in the list, "Face Recognition & Tracking", on my Intel Joule 570x board, 4GB of RAM and a 64 bit quad-core Intel® Atom™ processor at 1.7 GHz with 2.4 GHz burst and 4MB of Cache running a fresh Ubuntu 14.04, with two cameras streaming 320x240 10FPS, I only can get around 2 or 3 FPS for each camera and the CPU load is almost 100% while the memory usage is around 30%. It is almost the same on my laptop with a more powerful CPU and more RAM. Have you had better experiences?

Thanks, Vahid

mathieuduperre commented 7 years ago

hi, I found (i think) the reason for FPS drop. in the file camera.py under get_frame function, comment the portion where it messes with the frame rate. skipping that all together fixed a lot of bugs for me. Sleeping should not be required anyway as opencv does manage the fps itself. I'll add a check button in the UI to enable/disable that in the future.

Also for the record, I'm using an iphone app called live-reporter (free) which streams rtsp and face recognition works great with both camera.

BrandonJoffe commented 7 years ago

Hey @mathieuduperre,

you are right :)

However, the change in frame rate and the sleep function are significant if you are using more than one camera. When testing I found that one camera would unnecessarily consume more processing power than it needed and would starve the other processes. So I added the functionality to slow the frame rate. I'm sure there is a better way to do this, but for now, adding a check button to the dashboard would be great.

If you manage to get it done submit a pull request and i'll merge it with the current master branch.

The live-reporter app is a great find thanks for sharing!

Brandon