diff --git a/3rdparty/stasm4.0.0/CMakeLists.txt b/3rdparty/stasm4.0.0/CMakeLists.txt index 99da336..ffd7188 100644 --- a/3rdparty/stasm4.0.0/CMakeLists.txt +++ b/3rdparty/stasm4.0.0/CMakeLists.txt @@ -1,6 +1,10 @@ project(stasm) cmake_minimum_required(VERSION 2.8.6) +if(${CMAKE_VERSION} VERSION_GREATER 2.8.11) + cmake_policy(SET CMP0020 NEW) +endif() + # Global Settings set(CPACK_PACKAGE_NAME "Stasm") set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) @@ -29,7 +33,6 @@ if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /wd4267 /wd4307 /wd4308 /nologo") endif() -message("********* ${PROJECT_SOURCE_DIR} ************") add_subdirectory(${PROJECT_SOURCE_DIR}/stasm) # Package diff --git a/3rdparty/stasm4.0.0/stasm/include/stasm_lib.h b/3rdparty/stasm4.0.0/stasm/include/stasm_lib.h index 375de24..9980c48 100755 --- a/3rdparty/stasm4.0.0/stasm/include/stasm_lib.h +++ b/3rdparty/stasm4.0.0/stasm/include/stasm_lib.h @@ -62,6 +62,20 @@ #ifndef STASM_LIB_H #define STASM_LIB_H +#if defined STASM_LIBRARY +# if defined _WIN32 || defined __CYGWIN__ +# define STASM_EXPORT __declspec(dllexport) +# else +# define STASM_EXPORT __attribute__((visibility("default"))) +# endif +#else +# if defined _WIN32 || defined __CYGWIN__ +# define STASM_EXPORT __declspec(dllimport) +# else +# define STASM_EXPORT +# endif +#endif + #include "stasmcascadeclassifier.h" #define TRACE_IMAGES 0 // 1 to generate debugging images @@ -71,13 +85,13 @@ static const int stasm_NLANDMARKS = 77; // number of landmarks extern const char* const stasm_VERSION; -extern "C" -int stasm_init( // call once, at bootup + +STASM_EXPORT int stasm_init( // call once, at bootup const char* datadir, // in: directory of face detector files int trace); // in: 0 normal use, 1 trace to stdout and stasm.log -extern "C" -int stasm_open_image( // call once per image, detect faces + +STASM_EXPORT int stasm_open_image( // call once per image, detect faces const char* img, // in: gray image data, top left corner at 0,0 int width, // in: image width int height, // in: image height @@ -85,8 +99,8 @@ int stasm_open_image( // call once per image, detect faces int multiface, // in: 0=return only one face, 1=allow multiple faces int minwidth); // in: min face width as percentage of img width -extern "C" -int stasm_search_auto( // call repeatedly to find all faces + +STASM_EXPORT int stasm_search_auto( // call repeatedly to find all faces int* foundface, // out: 0=no more faces, 1=found face float* landmarks, // out: x0, y0, x1, y1, ..., caller must allocate const char* data, @@ -94,8 +108,8 @@ int stasm_search_auto( // call repeatedly to find all faces const int height, StasmCascadeClassifier cascade); -extern "C" -int stasm_search_single( // wrapper for stasm_search_auto and friends + +STASM_EXPORT int stasm_search_single( // wrapper for stasm_search_auto and friends int* foundface, // out: 0=no face, 1=found face float* landmarks, // out: x0, y0, x1, y1, ..., caller must allocate const char* img, // in: gray image data, top left corner at 0,0 @@ -105,8 +119,8 @@ int stasm_search_single( // wrapper for stasm_search_auto and friends const char* imgpath, // in: image path, used only for err msgs and debug const char* datadir); // in: directory of face detector files -extern "C" // find landmarks, no OpenCV face detect -int stasm_search_pinned( // call after the user has pinned some points + // find landmarks, no OpenCV face detect +STASM_EXPORT int stasm_search_pinned( // call after the user has pinned some points float* landmarks, // out: x0, y0, x1, y1, ..., caller must allocate const float* pinned, // in: pinned landmarks (0,0 points not pinned) const char* img, // in: gray image data, top left corner at 0,0 @@ -114,17 +128,17 @@ int stasm_search_pinned( // call after the user has pinned some points int height, // in: image height const char* imgpath); // in: image path, used only for err msgs and debug -extern "C" -const char* stasm_lasterr(void); // return string describing last error -extern "C" -void stasm_force_points_into_image( // force landmarks into image boundary +STASM_EXPORT const char* stasm_lasterr(void); // return string describing last error + + +STASM_EXPORT void stasm_force_points_into_image( // force landmarks into image boundary float* landmarks, // io int ncols, // in int nrows); // in -extern "C" -void stasm_convert_shape( // convert stasm 77 points to given number of points + +STASM_EXPORT void stasm_convert_shape( // convert stasm 77 points to given number of points float* landmarks, // io: return all points zero if can't do conversion int nlandmarks); // in: 77=nochange 76=stasm3 68=xm2vts 22=ar 20=bioid 17=me17 @@ -133,7 +147,7 @@ void stasm_convert_shape( // convert stasm 77 points to given number of points // trace=1. This function was added primarily for the programs that test // the stasm library. -extern "C" -void stasm_printf(const char* format, ...); // print to stdout and stasm.log + +STASM_EXPORT void stasm_printf(const char* format, ...); // print to stdout and stasm.log #endif // STASM_LIB_H diff --git a/3rdparty/stasm4.0.0/stasm/src/err.cpp b/3rdparty/stasm4.0.0/stasm/src/err.cpp index 3a1f922..aca7809 100755 --- a/3rdparty/stasm4.0.0/stasm/src/err.cpp +++ b/3rdparty/stasm4.0.0/stasm/src/err.cpp @@ -25,6 +25,8 @@ // // Copyright (C) 2005-2013, Stephen Milborrow +#include + #include "err.h" #include "misc.h" diff --git a/CMakeLists.txt b/CMakeLists.txt index ae967d4..a914153 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ if(${CMAKE_VERSION} VERSION_EQUAL 2.8.11) cmake_policy(SET CMP0020 OLD) endif() if(${CMAKE_VERSION} VERSION_GREATER 2.8.11) - cmake_policy(SET CMP0020 OLD) + cmake_policy(SET CMP0020 NEW) endif() if(${CMAKE_VERSION} VERSION_EQUAL 2.8.12) @@ -32,6 +32,9 @@ endif() if(${CMAKE_VERSION} VERSION_GREATER 2.8.12) cmake_policy(SET CMP0022 OLD) endif() +if(${CMAKE_VERSION} VERSION_GREATER 2.8.11) + cmake_policy(SET CMP0043 NEW) +endif() if(${CMAKE_SIZEOF_VOID_P} MATCHES 8) set(BITNESS 64) @@ -85,7 +88,7 @@ set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Qt5Core_QTMAIN_LIBRARIES}) # Find OpenCV find_package(OpenCV REQUIRED) -set(OPENCV_DEPENDENCIES opencv_calib3d opencv_core opencv_features2d opencv_flann opencv_gpu opencv_highgui opencv_imgproc opencv_ml opencv_nonfree opencv_objdetect opencv_photo opencv_video) +set(OPENCV_DEPENDENCIES opencv_calib3d opencv_core opencv_features2d opencv_flann opencv_gpu opencv_highgui opencv_imgproc opencv_ml opencv_nonfree opencv_objdetect opencv_photo opencv_video opencv_ocl) set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${OpenCV_LIBS}) # Find Alphanum diff --git a/openbr/plugins/stasm4.cmake b/openbr/plugins/stasm4.cmake index 874fca3..4634f74 100644 --- a/openbr/plugins/stasm4.cmake +++ b/openbr/plugins/stasm4.cmake @@ -3,15 +3,16 @@ set(BR_WITH_STASM4 ON CACHE BOOL "Build with Stasm") if(${BR_WITH_STASM4}) find_package(Stasm4 REQUIRED) - include_directories(${STASM4_INCLUDE_DIR}) + include_directories(${STASM4_DIR}/include) set(BR_THIRDPARTY_SRC ${BR_THIRDPARTY_SRC} plugins/stasm4.cpp) set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${STASM4_LIBS}) if(WIN32) - install(FILES ${STASM4_LIBS} DESTINATION bin) + install(DIRECTORY ${STASM4_DIR}/bin/ DESTINATION bin) + install(DIRECTORY ${STASM4_DIR}/lib/ DESTINATION lib) else() - install(FILES ${STASM4_LIBS} DESTINATION lib) + install(DIRECTORY ${STASM4_DIR}/lib/ DESTINATION lib) endif() install(DIRECTORY ${STASM4_INCLUDE_DIR}/ DESTINATION include) diff --git a/share/openbr/cmake/FindStasm4.cmake b/share/openbr/cmake/FindStasm4.cmake index 4c55bdc..60b3f7a 100644 --- a/share/openbr/cmake/FindStasm4.cmake +++ b/share/openbr/cmake/FindStasm4.cmake @@ -22,7 +22,10 @@ foreach(CACHE_VAR ${CACHE_VARS}) else() set(CACHE_VAR_TYPE :${CACHE_VAR_TYPE}) endif() - list(APPEND CMAKE_ARGS "-D${CACHE_VAR}${CACHE_VAR_TYPE}=${${CACHE_VAR}}") + + if(CACHE_VAR STREQUAL "CMAKE_PREFIX_PATH") + set(CMAKE_PREFIX_PATH "\"${${CACHE_VAR}}\"") + endif() endif() endforeach() @@ -31,14 +34,20 @@ find_path(STASM4_SOURCE_DIR stasm/include/stasm_lib.h ${CMAKE_SOURCE_DIR}/3rdpar set(STASM4_PREFIX "${CMAKE_BINARY_DIR}/stasm") set(STASM4_INSTALL_DIR "${CMAKE_BINARY_DIR}/stasm") +# ExternalProject_Add doesn't respect the ; path separator (i.e. ; don't get no respect) +string(REPLACE ";" "::" CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}") + # Have to use a name other than stasm so it doesn't conflict with the project itself ExternalProject_Add(external_stasm URL ${STASM4_SOURCE_DIR} PREFIX ${STASM4_PREFIX} - CMAKE_ARGS "${CMAKE_ARGS};-DCMAKE_INSTALL_PREFIX=" + LIST_SEPARATOR :: + CMAKE_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DCMAKE_INSTALL_PREFIX= + -DCMAKE_BUILD_TYPE=Release INSTALL_DIR ${STASM4_INSTALL_DIR} - BINARY_DIR "${STASM4_PREFIX}/lib" - ) + BINARY_DIR "${STASM4_PREFIX}/build" +) # We have to fake a library being created to force external_stasm to be built add_library(fake_stasm UNKNOWN IMPORTED) @@ -46,8 +55,9 @@ add_dependencies(fake_stasm external_stasm) ExternalProject_Get_Property(external_stasm install_dir) set(STASM4_FOUND TRUE) -set(STASM4_INCLUDE_DIR ${install_dir}/include) +set(STASM4_DIR ${install_dir}) set(STASM4_DATA_DIR ${install_dir}/src/external_stasm/data) -# We have to explicitly set these, because they aren't created by the time the calling project gets to this point -set(STASM4_LIBS ${install_dir}/lib/stasm/libstasm.dylib ${install_dir}/lib/stasm/libstasm.dylib) +link_directories(${install_dir}/lib) + +set(STASM4_LIBS stasm)