Enjoy the full power of CNN and computer vision finding faces on video and checking their presence in database with mse_checking_person_in_db.
We tried to use best libraries, namely face_recognition
and OpenCV
, to create this application.
Use this application to find faces from video and check their presence in database. The project supports .mp4 and .avi video formats.
System | Python | Distributions |
---|---|---|
Ubuntu 18.04 | 3.6+, pip3 | MongoDB |
If you don't have MongoDB, visit https://docs.mongodb.com/manual/administration/install-community/.
Make sure you have virtualenv
and cmake
.
Install them using:
pip3 install virtualenv
sudo apt-get install cmake
Open terminal and follow these steps:
- Clone this repo:
git clone https://github.com/moevm/mse_checking_person_in_db.git
- Change directory to
mse_checking_person_in_db
:cd mse_checking_person_in_db/
- Set up the environment:
./setup.sh
If
dlib
library has not been installed correctly by pip, install it manually using following set of commands.
In this case,dlib
would be installed in~/.dlib
folder.git clone https://github.com/davisking/dlib.git ~/.dlib cd ~/.dlib mkdir build; cd build; cmake ..; cmake --build . cd .. python3 setup.py install
Remember to launch MongoDB before using project:
sudo service mongod start
Further it's assumed that you launched MongoDB.
Open terminal in checking_person_in_db
directory and execute db_interface.py
:
python3 ./db_interface.py [--add-group, -ag][--path=directory]
More options:
--list, -l, show list of persons in db
--delete, -d delete person from db
--add-group, -ag add group of persons to db
--add-person, -ap add single person to db
--name name of person to add/remove
--path, path to image data
--help, -h print command line options
Open terminal and follow these steps:
-
Log in as root to use keyboard interrupts.
sudo su
-
Activate virtual environment:
source .venv/bin/activate
-
Change directory to
checking_person_in_db
:cd checking_person_in_db/
-
Execute person_checker.py:
python3 ./person_checker.py [options] [-s video source|--source=video source] Options: --source, -s file path or cam id --skip-frames number of skipped frames --tolerance comparison accuracy (from 0 to 1) --upsample-times processing quality --report, --no-report generate report --video, --no-video generate processed video --help, -h print command line options
If video is processed successfully, the message:
video_<timestamp>.mp4 created report.txt created
will be displayed in terminal. The output video (if you set
--video
flag) and the report will be created inchecking_person_in_db/out/
directory.
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. Report bugs at https://github.com/moevm/mse_checking_person_in_db/issues. If you are reporting a bug, please apply label "bug" and include:
- Any details about your local setup that might be helpful in troubleshooting;
- Detailed steps to reproduce the bug.
It's assumed that you launched MongoDB.
Let's create database and check faces presence on video.
Suppose you have video file "video.avi" and persons
directory tree as below:
.
+-- _persons
| +-- _person1
| +-- img1.png
| +-- img2.png
| ...
| +-- img<n>.png
| +-- _person2
| +-- ...
| ...
| +-- _person<n>
| +-- ...
Follow these steps:
-
Open terminal in
checking_person_in_db
and activatevirtualenv
:source .venv/bin/activate
-
Execute
db_interface.py
:python3 db_interface.py -ag persons
-
As
db_interface.py
completes runperson_checker.py
:python3 ./person_checker.py -s video.avi
If video file is processed succesfully, the output video with found faces
and the report will be created in checking_person_in_db/out/
directory.