如何重新编译opencv_traincascade(OpenCV 2.4)?

时间:2016-11-30 13:30:06

标签: macos opencv haar-classifier recompile

我想知道如何在macOS Sierra上编译opencv_traincascade程序。

我有traincascade的源代码(在文件夹/opencv-2.4.13/apps/traincascade/中)。但是,当我转到此文件夹并在终端上输入时:

cmake ..

它返回:

-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at haartraining/CMakeLists.txt:2 (ocv_check_dependencies):
  Unknown CMake command "ocv_check_dependencies".


CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.6)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

=>它不理解“ocv_check_dependencies”

这是CMakeLists.txt代码:

SET(OPENCV_TRAINCASCADE_DEPS opencv_core opencv_ml opencv_imgproc opencv_objdetect opencv_highgui opencv_calib3d opencv_video opencv_features2d opencv_flann opencv_legacy)
ocv_check_dependencies(${OPENCV_TRAINCASCADE_DEPS})

if(NOT OCV_DEPENDENCIES_FOUND)
  return()
endif()

project(traincascade)

ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
ocv_include_modules(${OPENCV_TRAINCASCADE_DEPS})

set(traincascade_files traincascade.cpp
  cascadeclassifier.cpp cascadeclassifier.h
  boost.cpp boost.h features.cpp traincascade_features.h
  haarfeatures.cpp haarfeatures.h
  lbpfeatures.cpp lbpfeatures.h
  HOGfeatures.cpp HOGfeatures.h
  imagestorage.cpp imagestorage.h)

set(the_target opencv_traincascade)
add_executable(${the_target} ${traincascade_files})
target_link_libraries(${the_target} ${OPENCV_TRAINCASCADE_DEPS} opencv_haartraining_engine)

set_target_properties(${the_target} PROPERTIES
                      DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
                      ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
                      RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
                      OUTPUT_NAME "opencv_traincascade")

if(ENABLE_SOLUTION_FOLDERS)
  set_target_properties(${the_target} PROPERTIES FOLDER "applications")
endif()

if(INSTALL_CREATE_DISTRIB)
  if(BUILD_SHARED_LIBS)
    install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev)
  endif()
else()
  install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev)
endif()

此外,这个问题引起了我的注意,因为我在训练过程中遇到了-featureType LBP。当我使用LBP功能训练我的面部检测器时,它显示:

Andy-Chen:Temp Training macpro$ opencv_traincascade -data data -vec faces_15000-80000.vec -bg neg.txt -numPos 4000 -numNeg 10000 -numStages 10 -w 21 -h 24 -featureType LBP
===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   4000 : 4000
NEG count : acceptanceRatio    10000 : 1

然后它保持这个状态几个小时没有任何进展。但是,如果我使用HAAR功能进行训练,一切正常。

因此,我想在traincascade的源代码中添加一些“cout”命令,以便我可以看到程序被卡住的位置,然后寻找解决方案或修改某些内容以使其可行。

我期待着您的帮助。非常感谢您的宝贵时间。

0 个答案:

没有答案