美文网首页人脸检测、物体检测
centerFace+ncnn编译(linux)

centerFace+ncnn编译(linux)

作者: Cat丹 | 来源:发表于2020-05-19 14:35 被阅读0次
    1. 安装opencv
      在官网下载最新的opencv,按照如下教程安装
      https://blog.csdn.net/AQRSXIAO/article/details/81458912
    2. 安装protobuf
      https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
    3. 编译ncnn
      https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-linux-x86
    4. 编译centerFace的prj-ncc
      我在这一步卡住了,主要是因为CMakeLists文件书写有问题,可能作者的ncnn安装后的目录结构与我的不一样。更改CMakeLists之后,就ok了。
    #1.cmake verson
    cmake_minimum_required(VERSION 2.8)
    
    set (DIR  "/your_dir/ncnn")
    
    
    #2.project name
    project(demo C CXX)
    
    #opencv
    find_package(OpenCV REQUIRED)
    
    #3.set environment variable
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    
    #4. include
    include_directories(${DIR}/src
                        ${DIR}/build/src
                        ${CMAKE_CURRENT_LIST_DIR}/cpp)
    
    # ncnn lib
    add_library( libncnn STATIC IMPORTED )
    set_target_properties(
            libncnn
            PROPERTIES IMPORTED_LOCATION
            ${DIR}/build/src/libncnn.a
    )
    
    # add OPENMP support 
    FIND_PACKAGE( OpenMP REQUIRED)
    if(OPENMP_FOUND)
    message("OPENMP FOUND")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
    endif()
    
    #6.source directory
    file(GLOB TEST_SRC ${CMAKE_CURRENT_LIST_DIR}/cpp/*.cpp
                       ${CMAKE_CURRENT_LIST_DIR}/demo.cpp)
    set(TEST_COMPILE_CODE ${TEST_SRC})
    
    
    add_executable(demo ${TEST_COMPILE_CODE})
    
    target_link_libraries(demo 
                          libncnn
                          ${OpenCV_LIBS}
                          )
    

    相关文章

      网友评论

        本文标题:centerFace+ncnn编译(linux)

        本文链接:https://www.haomeiwen.com/subject/mblbohtx.html