Commit e22d70a536816c5ef93323c8d76765679ecf82c9
1 parent
039db880
Working msvc compilation, added seemingly required ocl
Showing
6 changed files
with
64 additions
and
31 deletions
3rdparty/stasm4.0.0/CMakeLists.txt
| 1 | project(stasm) | 1 | project(stasm) |
| 2 | cmake_minimum_required(VERSION 2.8.6) | 2 | cmake_minimum_required(VERSION 2.8.6) |
| 3 | 3 | ||
| 4 | +if(${CMAKE_VERSION} VERSION_GREATER 2.8.11) | ||
| 5 | + cmake_policy(SET CMP0020 NEW) | ||
| 6 | +endif() | ||
| 7 | + | ||
| 4 | # Global Settings | 8 | # Global Settings |
| 5 | set(CPACK_PACKAGE_NAME "Stasm") | 9 | set(CPACK_PACKAGE_NAME "Stasm") |
| 6 | set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) | 10 | set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) |
| @@ -29,7 +33,6 @@ if(MSVC) | @@ -29,7 +33,6 @@ if(MSVC) | ||
| 29 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /wd4267 /wd4307 /wd4308 /nologo") | 33 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /wd4267 /wd4307 /wd4308 /nologo") |
| 30 | endif() | 34 | endif() |
| 31 | 35 | ||
| 32 | -message("********* ${PROJECT_SOURCE_DIR} ************") | ||
| 33 | add_subdirectory(${PROJECT_SOURCE_DIR}/stasm) | 36 | add_subdirectory(${PROJECT_SOURCE_DIR}/stasm) |
| 34 | 37 | ||
| 35 | # Package | 38 | # Package |
3rdparty/stasm4.0.0/stasm/include/stasm_lib.h
| @@ -62,6 +62,20 @@ | @@ -62,6 +62,20 @@ | ||
| 62 | #ifndef STASM_LIB_H | 62 | #ifndef STASM_LIB_H |
| 63 | #define STASM_LIB_H | 63 | #define STASM_LIB_H |
| 64 | 64 | ||
| 65 | +#if defined STASM_LIBRARY | ||
| 66 | +# if defined _WIN32 || defined __CYGWIN__ | ||
| 67 | +# define STASM_EXPORT __declspec(dllexport) | ||
| 68 | +# else | ||
| 69 | +# define STASM_EXPORT __attribute__((visibility("default"))) | ||
| 70 | +# endif | ||
| 71 | +#else | ||
| 72 | +# if defined _WIN32 || defined __CYGWIN__ | ||
| 73 | +# define STASM_EXPORT __declspec(dllimport) | ||
| 74 | +# else | ||
| 75 | +# define STASM_EXPORT | ||
| 76 | +# endif | ||
| 77 | +#endif | ||
| 78 | + | ||
| 65 | #include "stasmcascadeclassifier.h" | 79 | #include "stasmcascadeclassifier.h" |
| 66 | 80 | ||
| 67 | #define TRACE_IMAGES 0 // 1 to generate debugging images | 81 | #define TRACE_IMAGES 0 // 1 to generate debugging images |
| @@ -71,13 +85,13 @@ static const int stasm_NLANDMARKS = 77; // number of landmarks | @@ -71,13 +85,13 @@ static const int stasm_NLANDMARKS = 77; // number of landmarks | ||
| 71 | 85 | ||
| 72 | extern const char* const stasm_VERSION; | 86 | extern const char* const stasm_VERSION; |
| 73 | 87 | ||
| 74 | -extern "C" | ||
| 75 | -int stasm_init( // call once, at bootup | 88 | + |
| 89 | +STASM_EXPORT int stasm_init( // call once, at bootup | ||
| 76 | const char* datadir, // in: directory of face detector files | 90 | const char* datadir, // in: directory of face detector files |
| 77 | int trace); // in: 0 normal use, 1 trace to stdout and stasm.log | 91 | int trace); // in: 0 normal use, 1 trace to stdout and stasm.log |
| 78 | 92 | ||
| 79 | -extern "C" | ||
| 80 | -int stasm_open_image( // call once per image, detect faces | 93 | + |
| 94 | +STASM_EXPORT int stasm_open_image( // call once per image, detect faces | ||
| 81 | const char* img, // in: gray image data, top left corner at 0,0 | 95 | const char* img, // in: gray image data, top left corner at 0,0 |
| 82 | int width, // in: image width | 96 | int width, // in: image width |
| 83 | int height, // in: image height | 97 | int height, // in: image height |
| @@ -85,8 +99,8 @@ int stasm_open_image( // call once per image, detect faces | @@ -85,8 +99,8 @@ int stasm_open_image( // call once per image, detect faces | ||
| 85 | int multiface, // in: 0=return only one face, 1=allow multiple faces | 99 | int multiface, // in: 0=return only one face, 1=allow multiple faces |
| 86 | int minwidth); // in: min face width as percentage of img width | 100 | int minwidth); // in: min face width as percentage of img width |
| 87 | 101 | ||
| 88 | -extern "C" | ||
| 89 | -int stasm_search_auto( // call repeatedly to find all faces | 102 | + |
| 103 | +STASM_EXPORT int stasm_search_auto( // call repeatedly to find all faces | ||
| 90 | int* foundface, // out: 0=no more faces, 1=found face | 104 | int* foundface, // out: 0=no more faces, 1=found face |
| 91 | float* landmarks, // out: x0, y0, x1, y1, ..., caller must allocate | 105 | float* landmarks, // out: x0, y0, x1, y1, ..., caller must allocate |
| 92 | const char* data, | 106 | const char* data, |
| @@ -94,8 +108,8 @@ int stasm_search_auto( // call repeatedly to find all faces | @@ -94,8 +108,8 @@ int stasm_search_auto( // call repeatedly to find all faces | ||
| 94 | const int height, | 108 | const int height, |
| 95 | StasmCascadeClassifier cascade); | 109 | StasmCascadeClassifier cascade); |
| 96 | 110 | ||
| 97 | -extern "C" | ||
| 98 | -int stasm_search_single( // wrapper for stasm_search_auto and friends | 111 | + |
| 112 | +STASM_EXPORT int stasm_search_single( // wrapper for stasm_search_auto and friends | ||
| 99 | int* foundface, // out: 0=no face, 1=found face | 113 | int* foundface, // out: 0=no face, 1=found face |
| 100 | float* landmarks, // out: x0, y0, x1, y1, ..., caller must allocate | 114 | float* landmarks, // out: x0, y0, x1, y1, ..., caller must allocate |
| 101 | const char* img, // in: gray image data, top left corner at 0,0 | 115 | 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 | @@ -105,8 +119,8 @@ int stasm_search_single( // wrapper for stasm_search_auto and friends | ||
| 105 | const char* imgpath, // in: image path, used only for err msgs and debug | 119 | const char* imgpath, // in: image path, used only for err msgs and debug |
| 106 | const char* datadir); // in: directory of face detector files | 120 | const char* datadir); // in: directory of face detector files |
| 107 | 121 | ||
| 108 | -extern "C" // find landmarks, no OpenCV face detect | ||
| 109 | -int stasm_search_pinned( // call after the user has pinned some points | 122 | + // find landmarks, no OpenCV face detect |
| 123 | +STASM_EXPORT int stasm_search_pinned( // call after the user has pinned some points | ||
| 110 | float* landmarks, // out: x0, y0, x1, y1, ..., caller must allocate | 124 | float* landmarks, // out: x0, y0, x1, y1, ..., caller must allocate |
| 111 | const float* pinned, // in: pinned landmarks (0,0 points not pinned) | 125 | const float* pinned, // in: pinned landmarks (0,0 points not pinned) |
| 112 | const char* img, // in: gray image data, top left corner at 0,0 | 126 | 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 | @@ -114,17 +128,17 @@ int stasm_search_pinned( // call after the user has pinned some points | ||
| 114 | int height, // in: image height | 128 | int height, // in: image height |
| 115 | const char* imgpath); // in: image path, used only for err msgs and debug | 129 | const char* imgpath); // in: image path, used only for err msgs and debug |
| 116 | 130 | ||
| 117 | -extern "C" | ||
| 118 | -const char* stasm_lasterr(void); // return string describing last error | ||
| 119 | 131 | ||
| 120 | -extern "C" | ||
| 121 | -void stasm_force_points_into_image( // force landmarks into image boundary | 132 | +STASM_EXPORT const char* stasm_lasterr(void); // return string describing last error |
| 133 | + | ||
| 134 | + | ||
| 135 | +STASM_EXPORT void stasm_force_points_into_image( // force landmarks into image boundary | ||
| 122 | float* landmarks, // io | 136 | float* landmarks, // io |
| 123 | int ncols, // in | 137 | int ncols, // in |
| 124 | int nrows); // in | 138 | int nrows); // in |
| 125 | 139 | ||
| 126 | -extern "C" | ||
| 127 | -void stasm_convert_shape( // convert stasm 77 points to given number of points | 140 | + |
| 141 | +STASM_EXPORT void stasm_convert_shape( // convert stasm 77 points to given number of points | ||
| 128 | float* landmarks, // io: return all points zero if can't do conversion | 142 | float* landmarks, // io: return all points zero if can't do conversion |
| 129 | int nlandmarks); // in: 77=nochange 76=stasm3 68=xm2vts 22=ar 20=bioid 17=me17 | 143 | int nlandmarks); // in: 77=nochange 76=stasm3 68=xm2vts 22=ar 20=bioid 17=me17 |
| 130 | 144 | ||
| @@ -133,7 +147,7 @@ void stasm_convert_shape( // convert stasm 77 points to given number of points | @@ -133,7 +147,7 @@ void stasm_convert_shape( // convert stasm 77 points to given number of points | ||
| 133 | // trace=1. This function was added primarily for the programs that test | 147 | // trace=1. This function was added primarily for the programs that test |
| 134 | // the stasm library. | 148 | // the stasm library. |
| 135 | 149 | ||
| 136 | -extern "C" | ||
| 137 | -void stasm_printf(const char* format, ...); // print to stdout and stasm.log | 150 | + |
| 151 | +STASM_EXPORT void stasm_printf(const char* format, ...); // print to stdout and stasm.log | ||
| 138 | 152 | ||
| 139 | #endif // STASM_LIB_H | 153 | #endif // STASM_LIB_H |
3rdparty/stasm4.0.0/stasm/src/err.cpp
CMakeLists.txt
| @@ -23,7 +23,7 @@ if(${CMAKE_VERSION} VERSION_EQUAL 2.8.11) | @@ -23,7 +23,7 @@ if(${CMAKE_VERSION} VERSION_EQUAL 2.8.11) | ||
| 23 | cmake_policy(SET CMP0020 OLD) | 23 | cmake_policy(SET CMP0020 OLD) |
| 24 | endif() | 24 | endif() |
| 25 | if(${CMAKE_VERSION} VERSION_GREATER 2.8.11) | 25 | if(${CMAKE_VERSION} VERSION_GREATER 2.8.11) |
| 26 | - cmake_policy(SET CMP0020 OLD) | 26 | + cmake_policy(SET CMP0020 NEW) |
| 27 | endif() | 27 | endif() |
| 28 | 28 | ||
| 29 | if(${CMAKE_VERSION} VERSION_EQUAL 2.8.12) | 29 | if(${CMAKE_VERSION} VERSION_EQUAL 2.8.12) |
| @@ -32,6 +32,9 @@ endif() | @@ -32,6 +32,9 @@ endif() | ||
| 32 | if(${CMAKE_VERSION} VERSION_GREATER 2.8.12) | 32 | if(${CMAKE_VERSION} VERSION_GREATER 2.8.12) |
| 33 | cmake_policy(SET CMP0022 OLD) | 33 | cmake_policy(SET CMP0022 OLD) |
| 34 | endif() | 34 | endif() |
| 35 | +if(${CMAKE_VERSION} VERSION_GREATER 2.8.11) | ||
| 36 | + cmake_policy(SET CMP0043 NEW) | ||
| 37 | +endif() | ||
| 35 | 38 | ||
| 36 | if(${CMAKE_SIZEOF_VOID_P} MATCHES 8) | 39 | if(${CMAKE_SIZEOF_VOID_P} MATCHES 8) |
| 37 | set(BITNESS 64) | 40 | set(BITNESS 64) |
| @@ -85,7 +88,7 @@ set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Qt5Core_QTMAIN_LIBRARIES}) | @@ -85,7 +88,7 @@ set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Qt5Core_QTMAIN_LIBRARIES}) | ||
| 85 | 88 | ||
| 86 | # Find OpenCV | 89 | # Find OpenCV |
| 87 | find_package(OpenCV REQUIRED) | 90 | find_package(OpenCV REQUIRED) |
| 88 | -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) | 91 | +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) |
| 89 | set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${OpenCV_LIBS}) | 92 | set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${OpenCV_LIBS}) |
| 90 | 93 | ||
| 91 | # Find Alphanum | 94 | # Find Alphanum |
openbr/plugins/stasm4.cmake
| @@ -3,15 +3,16 @@ set(BR_WITH_STASM4 ON CACHE BOOL "Build with Stasm") | @@ -3,15 +3,16 @@ set(BR_WITH_STASM4 ON CACHE BOOL "Build with Stasm") | ||
| 3 | if(${BR_WITH_STASM4}) | 3 | if(${BR_WITH_STASM4}) |
| 4 | find_package(Stasm4 REQUIRED) | 4 | find_package(Stasm4 REQUIRED) |
| 5 | 5 | ||
| 6 | - include_directories(${STASM4_INCLUDE_DIR}) | 6 | + include_directories(${STASM4_DIR}/include) |
| 7 | 7 | ||
| 8 | set(BR_THIRDPARTY_SRC ${BR_THIRDPARTY_SRC} plugins/stasm4.cpp) | 8 | set(BR_THIRDPARTY_SRC ${BR_THIRDPARTY_SRC} plugins/stasm4.cpp) |
| 9 | set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${STASM4_LIBS}) | 9 | set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${STASM4_LIBS}) |
| 10 | 10 | ||
| 11 | if(WIN32) | 11 | if(WIN32) |
| 12 | - install(FILES ${STASM4_LIBS} DESTINATION bin) | 12 | + install(DIRECTORY ${STASM4_DIR}/bin/ DESTINATION bin) |
| 13 | + install(DIRECTORY ${STASM4_DIR}/lib/ DESTINATION lib) | ||
| 13 | else() | 14 | else() |
| 14 | - install(FILES ${STASM4_LIBS} DESTINATION lib) | 15 | + install(DIRECTORY ${STASM4_DIR}/lib/ DESTINATION lib) |
| 15 | endif() | 16 | endif() |
| 16 | 17 | ||
| 17 | install(DIRECTORY ${STASM4_INCLUDE_DIR}/ DESTINATION include) | 18 | install(DIRECTORY ${STASM4_INCLUDE_DIR}/ DESTINATION include) |
share/openbr/cmake/FindStasm4.cmake
| @@ -22,7 +22,10 @@ foreach(CACHE_VAR ${CACHE_VARS}) | @@ -22,7 +22,10 @@ foreach(CACHE_VAR ${CACHE_VARS}) | ||
| 22 | else() | 22 | else() |
| 23 | set(CACHE_VAR_TYPE :${CACHE_VAR_TYPE}) | 23 | set(CACHE_VAR_TYPE :${CACHE_VAR_TYPE}) |
| 24 | endif() | 24 | endif() |
| 25 | - list(APPEND CMAKE_ARGS "-D${CACHE_VAR}${CACHE_VAR_TYPE}=${${CACHE_VAR}}") | 25 | + |
| 26 | + if(CACHE_VAR STREQUAL "CMAKE_PREFIX_PATH") | ||
| 27 | + set(CMAKE_PREFIX_PATH "\"${${CACHE_VAR}}\"") | ||
| 28 | + endif() | ||
| 26 | endif() | 29 | endif() |
| 27 | endforeach() | 30 | endforeach() |
| 28 | 31 | ||
| @@ -31,14 +34,20 @@ find_path(STASM4_SOURCE_DIR stasm/include/stasm_lib.h ${CMAKE_SOURCE_DIR}/3rdpar | @@ -31,14 +34,20 @@ find_path(STASM4_SOURCE_DIR stasm/include/stasm_lib.h ${CMAKE_SOURCE_DIR}/3rdpar | ||
| 31 | set(STASM4_PREFIX "${CMAKE_BINARY_DIR}/stasm") | 34 | set(STASM4_PREFIX "${CMAKE_BINARY_DIR}/stasm") |
| 32 | set(STASM4_INSTALL_DIR "${CMAKE_BINARY_DIR}/stasm") | 35 | set(STASM4_INSTALL_DIR "${CMAKE_BINARY_DIR}/stasm") |
| 33 | 36 | ||
| 37 | +# ExternalProject_Add doesn't respect the ; path separator (i.e. ; don't get no respect) | ||
| 38 | +string(REPLACE ";" "::" CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}") | ||
| 39 | + | ||
| 34 | # Have to use a name other than stasm so it doesn't conflict with the project itself | 40 | # Have to use a name other than stasm so it doesn't conflict with the project itself |
| 35 | ExternalProject_Add(external_stasm | 41 | ExternalProject_Add(external_stasm |
| 36 | URL ${STASM4_SOURCE_DIR} | 42 | URL ${STASM4_SOURCE_DIR} |
| 37 | PREFIX ${STASM4_PREFIX} | 43 | PREFIX ${STASM4_PREFIX} |
| 38 | - CMAKE_ARGS "${CMAKE_ARGS};-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" | 44 | + LIST_SEPARATOR :: |
| 45 | + CMAKE_ARGS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} | ||
| 46 | + -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> | ||
| 47 | + -DCMAKE_BUILD_TYPE=Release | ||
| 39 | INSTALL_DIR ${STASM4_INSTALL_DIR} | 48 | INSTALL_DIR ${STASM4_INSTALL_DIR} |
| 40 | - BINARY_DIR "${STASM4_PREFIX}/lib" | ||
| 41 | - ) | 49 | + BINARY_DIR "${STASM4_PREFIX}/build" |
| 50 | +) | ||
| 42 | 51 | ||
| 43 | # We have to fake a library being created to force external_stasm to be built | 52 | # We have to fake a library being created to force external_stasm to be built |
| 44 | add_library(fake_stasm UNKNOWN IMPORTED) | 53 | add_library(fake_stasm UNKNOWN IMPORTED) |
| @@ -46,8 +55,9 @@ add_dependencies(fake_stasm external_stasm) | @@ -46,8 +55,9 @@ add_dependencies(fake_stasm external_stasm) | ||
| 46 | ExternalProject_Get_Property(external_stasm install_dir) | 55 | ExternalProject_Get_Property(external_stasm install_dir) |
| 47 | 56 | ||
| 48 | set(STASM4_FOUND TRUE) | 57 | set(STASM4_FOUND TRUE) |
| 49 | -set(STASM4_INCLUDE_DIR ${install_dir}/include) | 58 | +set(STASM4_DIR ${install_dir}) |
| 50 | set(STASM4_DATA_DIR ${install_dir}/src/external_stasm/data) | 59 | set(STASM4_DATA_DIR ${install_dir}/src/external_stasm/data) |
| 51 | 60 | ||
| 52 | -# We have to explicitly set these, because they aren't created by the time the calling project gets to this point | ||
| 53 | -set(STASM4_LIBS ${install_dir}/lib/stasm/libstasm.dylib ${install_dir}/lib/stasm/libstasm.dylib) | 61 | +link_directories(${install_dir}/lib) |
| 62 | + | ||
| 63 | +set(STASM4_LIBS stasm) |