Qengineering / Face-Recognition-Raspberry-Pi-64-bits

Recognize 2000+ faces on your Raspberry Pi 4 with database auto-fill and anti-spoofing
https://qengineering.eu/deep-learning-examples-on-raspberry-32-64-os.html
BSD 3-Clause "New" or "Revised" License
69 stars 19 forks source link

Compile with cmake #12

Open camillalc opened 2 years ago

camillalc commented 2 years ago

Hello,

Nice!! Thanks for sharing the source code.

You provided in #10 one example of how to compile with g++, but how can i create a CMakeLists.txt to compile using cmake?

Rgrds, Camilla

Qengineering commented 2 years ago

To use CMake. Assuming your in the 'main' directory.

.
├── bin
├── CMakeLists.txt
├── FaceRecognition.cbp
├── FaceRecognition.depend
├── FaceRecognition.layout
├── Graham Norton.jpg
├── img
├── include
├── LICENSE
├── models
├── Norton_2.mp4
├── Norton_A.mp4
├── obj
├── README.md
└── src

Create a build folder

$ mkdir build
$ cd build

Run CMake and Make

$ cmake ..
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr/local (found version "4.5.1") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/software/Face-Recognition-Raspberry-Pi-64-bits/build

$  make  -j4
Scanning dependencies of target FaceRecognition
[ 37%] Building CXX object CMakeFiles/FaceRecognition.dir/src/TMtCNN.cpp.o
[ 37%] Building CXX object CMakeFiles/FaceRecognition.dir/src/main.cpp.o
[ 37%] Building CXX object CMakeFiles/FaceRecognition.dir/src/TBlur.cpp.o
[ 50%] Building CXX object CMakeFiles/FaceRecognition.dir/src/TLive.cpp.o
[ 62%] Building CXX object CMakeFiles/FaceRecognition.dir/src/TRetina.cpp.o
[ 75%] Building CXX object CMakeFiles/FaceRecognition.dir/src/TWarp.cpp.o
[ 87%] Building CXX object CMakeFiles/FaceRecognition.dir/src/TArcface.cpp.o
[100%] Linking CXX executable ../FaceRecognition
[100%] Built target FaceRecognition

Find the executable in the 'main' folder (because of the other directories models and img).

$ cd ..
$ tree -L 1
.
├── bin
├── build
├── CMakeLists.txt
├── FaceRecognition
├── FaceRecognition.cbp
├── FaceRecognition.depend
├── FaceRecognition.layout
├── Graham Norton.jpg
├── img
├── include
├── LICENSE
├── models
├── Norton_2.mp4
├── Norton_A.mp4
├── obj
├── README.md
└── src

Run

$ ./FaceRecognition

Once FaceRecognition works, you may remove the build directory, since we don't need it any more.

$ sudo rm -rf build
camillalc commented 2 years ago

Thank you!!

roksage commented 2 years ago

Hello still can't find solution i followed these steps and stil strugle to run script. After running cmake .. as in example i tried to run make -j4 but nothing happens. Maybe im doing this step in wrong folder (tried running make -j4 everywhere i could)? Or make -j4 needs attributes?

I used fresh SD-image 64bit

Thank you for helping me. Want to run face recognition doors so much.

image

Qengineering commented 2 years ago

Look in the parent folder, not the build folder as it holds only temporarily files. You make gives on errors so it succeeded. So, from your location ..../build $ cd .. and you find FaceRecognition.

$ cd ..
$ tree -L 1
.
├── bin
├── build
├── CMakeLists.txt
├── FaceRecognition
├── FaceRecognition.cbp
├── FaceRecognition.depend
├── FaceRecognition.layout
├── Graham Norton.jpg
├── img
├── include
├── LICENSE
├── models
├── Norton_2.mp4
├── Norton_A.mp4
├── obj
├── README.md
└── src
roksage commented 2 years ago

Once again i did fresh install. After fresh install i used commands "sudo apt update" ; "sudo apt install tightvncserver"

And then followed steps but still cant see the FaceRecognition file. Because make -j4 did nothing :/.

Maybe "sudo apt update" ruins everything?

Using 2gb raspb 4 version

Upade: tried once again on fresh install without "sudo apt update", no progress

image

Qengineering commented 2 years ago

For your convenience I've posted a video on Gdrive on how to install and compile the software. I've used the Bullseye 64-bits OS in the video. The procedure is identical on a Buster 64-bit OS.

roksage commented 2 years ago

Eh... Thank you a lot. I was using Face-Recognition pre-downloaded in SD-image. CMakeLists.txt wasn't there and I just created an empty file :)... named CMakeLists.txt. I thought what was way to go. Thank you a lot once again.