Home surveillance with face recognition (on Jetson Nano)

As I had a IP-Webcam laying around and my Jetson Nano was idling recently I forked an abandoned repo with a home surveillance system that I liked and made it working on the Nano: https://github.com/domcross/home_surveillance

This is still work in progress and will probably not run “out of the box” as I might have missed to include some dependencies, but maybe some people here are interested. Any suggestions and comments welcome!

1 Like

There is a Docker image available now (tested on Jetson Nano but should run on TX1, TX2, Xavier AGX and NX as well). See the github repo for details…
Docker image seems to be broken. I will report back in this thread when I found a way to create a functional docker image…

Cool! You might consider posting this in the Jetson Projects forum as well. I have forked it and might commit some changes at some point this week. It aligns with some things I am working on myself.

As I forked the home surveillance system from a four years old repo a lot of libraries were outdated. While updating the libraries I look out for versions that support the Nanos GPU.

One of the core libs is OpenCV. Turns out that the key function for face detection - CascadeClassifier - is only supported up to CUDA version 7.5 in OpenCV - while the latest Jetpack for Nano has 10.0. So I looked out for alternatives and found “dlib” and “face_recognition” - both claiming to support CUDA/GPU for improved performance. So I did a little benchmark for this specific function - with a surprising result: OpenCV on CPU is five to ten times faster than dlib. (face_recognition is more or less a wrapper for dlib so it was even a little slower than dlib itself).

Next: benchmarking face recognition…

OpenCV is well optimized for CPU. It’s not really designed to use the GPU unless you’re using CUDA specific functions and GpuMat instead of Mat. Even then, it might not be optimal for Tegra.

If you want an optimal face recognition solution, you could try replacing the innards of your app with something DeepStream related, possibly running in a separate process, managed by Python.

There is an example of how to use Deepstream for face redaction here, and a canned model with example usage here that you can use to find faces.

Rather than redact later in the pipeline, however, you could run a secondary engine instead (example in deepstream_test_2) to recognise the detected face, but you would have to find, convert, and/or build a trained model.

If you know some c++ you could also use the model as mentioned, but later in the pipeline use OpenCV and this example code to do what you want.

Thanks again for the valuable input. Indeed OpenCV seems to be highly optimized - I found more algorithms for face detection and again the OpenCV DNN models beat Dlib and others. Time for more benchmarking…

The Deepstream path is very interesting but would require a major rework of the application, so i will leave that for the followup project: detection and identification of small airplanes that fly above my house (I live near to a small airfield…)

1 Like

I did some test with all kind of face_rec libs and can confirm that opencv runs mostly faster on cpu as with gpu.
With my rtsp ip cams, i run into the problem, that the image is 30-60sec behind realtime. I want to use it, as a door opener for the front gate, but with a 60sec delay this makes no sense.

Your fork looks really awesome on your Screenshots!! This is exactly what im looking for. I would love to test it, but as you allready wrote, the docker image is broken. It cant import flask.
I hope, that you could find some time to fix this.

1 Like