当前位置: 首页 > 工具软件 > ncnn > 使用案例 >

ncnn-入门1

岳和泽
2023-12-01

先贴几个博客!!!

ncnn-arm编译:https://www.cnblogs.com/crazybird123/p/9952256.html

mtnn模型训练源代码:https://github.com/Seanlinx/mtcnn

mtnn快速检测人脸:https://github.com/ElegantGod/ncnn

mtcnn简化版(裁剪):https://github.com/cpuimage/MTCNN

编译arm版mtcnn人脸检测:

1、修改ncnn目录下的CMakeList.txt文件,如下

#if(NCNN_OPENMP)
#    find_package(OpenMP)
#    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
#    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
#endif()
SET(CROSS_COMPILE 1)

IF(CROSS_COMPILE)

SET(CMAKE_SYSTEM_NAME Linux)

SET(TOOLCHAIN_DIR "/opt/opt/FriendlyARM/toolschain/4.5.1")

set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/arm-linux-g++)
set(CMAKE_C_COMPILER   ${TOOLCHAIN_DIR}/bin/arm-linux-gcc)
set(GNU_FLAGS "-mfpu=vfp -fPIC")
set(CMAKE_CXX_FLAGS "${GNU_FLAGS} ")
set(CMAKE_C_FLAGS "${GNU_FLAGS}  ")

SET(CMAKE_FIND_ROOT_PATH  ${TOOLCHAIN_DIR}
 ${TOOLCHAIN_DIR}/arm-none-linux-gnueabi/include
 ${TOOLCHAIN_DIR}/arm-none-linux-gnueabi/lib )

ENDIF(CROSS_COMPILE)

add_definitions(-Wall -Wextra)

add_definitions(-fPIC)
#add_definitions(-Ofast)

2、cmake CMakeList.txt &&make

ERROR1:出现找不到pthread dlopen的错误,修改mtcnn目录下的CMakeList.txt 如下

set(OpenCV_DIR /usr/local/opencv-arm/)
add_executable(mtcnn mtcnn.cpp)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src)
include_directories(/usr/local/opencv-arm/include)


target_link_libraries(mtcnn ncnn dl pthread rt -L"/usr/local/opencv-arm/lib" opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs)

warning1:

needed by /usr/local/opencv-arm/lib/libopencv_highgui.so, not found (try using -rpath or -rpath-link)

将libopencv_* 动态库copy到/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/lib下,再次make就可以了!!

3、之前移植opencv到arm板上进行人脸采集,采集效果不好,而且采集时间太长

现在移植ncnn的代码进行人脸采集,完全可以做到像手机一样的效果,识别出人脸,很给力!!!

 类似资料: