ShiqiYu / ShiqiYu/libfacedetection

how to build on armv7l raspberry pi 4b raspbian buster - code share

Open
#355 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
12.8k
Forks
3k
PR merge metrics
No merged PRs in 30d

Description

i`ve just successfully built library and examples on raspberry pi.
so i would like to share instructions to reproduce:

 git clone https://github.com/ShiqiYu/libfacedetection.git

cd libfacedetection
mkdir build && cd build

cmake -DENABLE_NEON=ON -DCMAKE_BUILD_TYPE=RELEASE -DUSE_OPENMP=OFF -DENABLE_AVX2=OFF -DDEMO=OFF -DCMAKE_CXX_FLAGS:STRING="-march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a72 -Wno-psabi" -DCMAKE_C_FLAGS:STRING="-march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a72 -Wno-psabi" -DCMAKE_ASM_FLAGS:STRING="-march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a72 -g" ..

*Replace -mtune=cortex-a15 with -mtune=cortex-a53 for RPi3 and -mtune=cortex-a72 for RPi4.

make
sudo make install

cd ..
cd example

nano CMakeLists.txt
cmake_minimum_required( VERSION 2.8 )
project( example )
find_package( OpenCV REQUIRED )
message(STATUS "OpenCV_LIBS = ${OpenCV_LIBS}")
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( detect-image detect-image.cpp )
add_executable( detect-camera detect-camera.cpp )
target_link_libraries( detect-image ${OpenCV_LIBS} )
#target_link_libraries( detect-image /libfacedetection/build/install/lib/libfacedetection.so )
target_link_libraries( detect-image /home/al/Desktop/projects/libfacedetection/build/install/lib/libfacedetection.so )
#target_link_libraries( detect-image /opencv/build/lib/libopencv_highgui.a )
target_link_libraries( detect-image /usr/local/lib/libopencv_highgui.so )
target_link_libraries( detect-image /usr/local/lib/libopencv_imgproc.so )
target_link_libraries( detect-image /usr/local/lib/libopencv_core.so )
target_link_libraries( detect-image /usr/local/lib/libopencv_imgcodecs.so )
target_link_libraries( detect-camera ${OpenCV_LIBS} )
#target_link_libraries( detect-camera /libfacedetection/build/install/lib/libfacedetection.so )
target_link_libraries( detect-camera /home/al/Desktop/projects/libfacedetection/build/install/lib/libfacedetection.a )
target_link_libraries( detect-camera /usr/local/lib/libopencv_highgui.so )
target_link_libraries( detect-camera /usr/local/lib/libopencv_video.so )
target_link_libraries( detect-camera /usr/local/lib/libopencv_imgproc.so )
target_link_libraries( detect-camera /usr/local/lib/libopencv_core.so )
target_link_libraries( detect-camera /usr/local/lib/libopencv_videoio.so )

nano detect-camera.cpp
	/home/pi/libfacedetection/src/facedetectcnn.h
nano detect-image.cpp
	/home/pi/libfacedetection/src/facedetectcnn.h

nano /home/pi/libfacedetection/src/facedetectcnn.h
	/home/pi/libfacedetection/build/facedetection_export.h
mkdir build
cd  build
cmake ..
make

./detect-image image.jpg

it works but i dont think fast enough:

./detect-image img_640x480.jpg 
time = 607.191ms
2 faces detected.
face 0: confidence=91, [171, 265, 35, 48] (179,285) (195,285) (186,295) (181,301) (193,302)
face 1: confidence=34, [446, 207, 56, 67] (460,230) (481,230) (467,241) (461,254) (477,252)

is it good result for edge device ?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ARM build commands and the example files example/CMakeLists.txt, detect-camera.cpp, detect-image.cpp, and src/facedetectcnn.h. Reproduce the Raspberry Pi build if hardware is available, then document a concise, portable procedure and the reported performance result; completion should make the setup reproducible without user-specific paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, opencv, raspberry-pi
Domain
build-system, documentation, embedded-iot
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.