1

I would like to know How to compile ONLY the program opencv_traincascade on macOS Sierra.

I have the source code of the traincascade (in the folder /opencv-2.4.13/apps/traincascade/). However, when I go to this folder and type on terminal:

cmake ..

It returns:

-- 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!

=> It does not understand the "ocv_check_dependencies"

Here is the CMakeLists.txt code:

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()

In addition, this question raised on my mind because I got stuck in the training process with -featureType LBP . When I train my face detector with LBP feature, it shows:

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

and then it keeps this status for several hours without any progress. However, if I train with HAAR feature, everything works fine.

Thus, I want to add some "cout" commands to the source code of traincascade so that I can see where the program gets stuck and then look for a solution or modify something to make it workable.

I look forward to hearing from your help. Thank you very much for your time.

  • why not compile all, libaries and tools (start cmake in the base directory)? – Micka Nov 30 '16 at 13:41
  • It takes too much time to me. Because I need only the traincascade thus training the whole library is waste of time. – Tinh-Chi Tran Dec 01 '16 at 00:51
  • compiling the whole library is probably much faster than searching for a solution to only compile tje tools. But good luck! – Micka Dec 01 '16 at 06:25
  • Micka: ok bro, I'll try this method. However, I installed OpenCV via Annaconda, could I change the source code of OpenCV (mentioned above) and compile them with Annaconda? – Tinh-Chi Tran Dec 01 '16 at 12:24

0 Answers0