![e4728d2a03b1fc6be2550ee11f888ce8.png](https://i-blog.csdnimg.cn/blog_migrate/51341d40036730bb76a005cd2976f220.jpeg)
libfacedetection是基于SSD架构的人脸检测算法,github地址:https://github.com/ShiqiYu/libfacedetection
号称最快的人脸检测算法,接下来笔者将验证它的推理速度究竟有多快。
由于项目工程是c++的,且模型也编译到c++文件中,所以先验证cpu上的推理速度。
1 x86编译
cmake .. -DCMAKE_INSTALL_PREFIX=install -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DDEMO=ON
make
make install
demo可以跑起来,模型的权重变量已经在cpp文件中了,不依赖模型。
2 交叉编译修改
修改CMakeLists.txt,交叉编译使用自定义的opencv库(仅涉及demo部分)
增加:
option(ARM_PLATFORM "Use Platform" OFF)
修改
if (DEMO)
...
endif()
改为
if (DEMO)
if(ARM_PLATFORM)
link_directories(/home/tzl/box/third_party/hi3559av100/opencv340)
include_directories(/home/tzl/box/third_party/hi3559av100/opencv340/inc)
set(OpenCV_LIBS libimgcodecs.a libimgproc.a libcore.a)
link_directories(/home/tzl/box/third_party/hi3559av100/png)
include_directories(/home/tzl/box/third_party/hi3559av100/png/inc)
set(Png_LIBS libpng.a)
link_directories(/home/tzl/box/third_party/hi3559av100/libjpeg)
include_directories(/home/tzl/box/third_party/hi3559av100/libjpeg/inc)
set(Jpeg_LIBS libjpeg.a libsimd.a libturbojpeg.a)
link_directories(/home/tzl/box/third_party/hi3559av100/zlib)
include_directories(/home/tzl/box/third_party/hi3559av100/zlib/inc)
set(Zlib_LIBS libzlib.a)
add_executable(detect-image-demo ${fdt_base_dir}/example/detect-image.cpp)
target_link_libraries(detect-image-demo ${fdt_lib_name} ${OpenCV_LIBS} ${Png_LIBS} ${Jpeg_LIBS} ${Zlib_LIBS})
#add_executable(detect-camera-demo ${fdt_base_dir}/example/detect-camera.cpp)
#target_link_libraries(detect-camera-demo ${fdt_lib_name} ${OpenCV_LIBS})
#add_executable(benchmark ${fdt_base_dir}/example/benchmark.cpp)
#target_link_libraries(benchmark ${fdt_lib_name} ${OpenCV_LIBS})
else()
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(detect-image-demo ${fdt_base_dir}/example/detect-image.cpp)
target_link_libraries(detect-image-demo ${fdt_lib_name} ${OpenCV_LIBS})
add_executable(detect-camera-demo ${fdt_base_dir}/example/detect-camera.cpp)
target_link_libraries(detect-camera-demo ${fdt_lib_name} ${OpenCV_LIBS})
add_executable(benchmark ${fdt_base_dir}/example/benchmark.cpp)
target_link_libraries(benchmark ${fdt_lib_name} ${OpenCV_LIBS})
endif()
endif()
3 hi3559A交叉编译
cmake -DCMAKE_INSTALL_PREFIX=install -DENABLE_NEON=ON -DENABLE_AVX2=OFF - DCMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=ON -DDEMO=ON -DARM_PLATFORM=ON -DCMAKE_TOOLCHAIN_FILE=../aarch64-toolchain.cmake ../
4 cpu推理时间
图片大小:1024*576
intel i7-7700K:70-90ms
hi3559a:1~1.5s,开启neon和不开启时间差不多,好像不开速度更快些
5 总结
总体来说,纯cpu跑的效果并不理想,由于时间关系笔者没有用多线程验证,但是于老师的开源项目还是非常nice,源代码很值得研究,对于理解深度学习和卷积非常有帮助。