diff --git a/sdk/plugins/nec3.cmake b/sdk/plugins/nec3.cmake index af22782..95cdd24 100644 --- a/sdk/plugins/nec3.cmake +++ b/sdk/plugins/nec3.cmake @@ -1,4 +1,4 @@ -set(BR_WITH_NEC3 OFF CACHE BOOL "Build with NEC NeoFaceDSK 3") +set(BR_WITH_NEC3 OFF CACHE BOOL "Build with NEC NeoFaceSDK 3") if(${BR_WITH_NEC3}) find_package(NEC3 REQUIRED) diff --git a/sdk/plugins/pbd.cpp b/sdk/plugins/pbd.cpp index 94fc40f..f9e8b86 100644 --- a/sdk/plugins/pbd.cpp +++ b/sdk/plugins/pbd.cpp @@ -34,11 +34,11 @@ class PBDInitializer : public Initializer void initialize() const { - Globals->abbreviations.insert("RectFromEyes","RectFromLandmarks([9, 10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 25],10,6.0)"); - Globals->abbreviations.insert("RectFromNose","RectFromLandmarks([0, 1, 2, 3, 4, 5, 6, 7, 8],10)"); - Globals->abbreviations.insert("RectFromBrow","RectFromLandmarks([15, 16, 17, 18, 19, 26, 27, 28, 29, 30],10)"); - Globals->abbreviations.insert("RectFromMouth","RectFromLandmarks([31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],10)"); - Globals->abbreviations.insert("RectFromJaw","RectFromLandmarks([51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67],10)"); + Globals->abbreviations.insert("RectFromPBDEyes","RectFromLandmarks([9, 10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 25],10,6.0)"); + Globals->abbreviations.insert("RectFromPBDNose","RectFromLandmarks([0, 1, 2, 3, 4, 5, 6, 7, 8],10)"); + Globals->abbreviations.insert("RectFromPBDBrow","RectFromLandmarks([15, 16, 17, 18, 19, 26, 27, 28, 29, 30],10)"); + Globals->abbreviations.insert("RectFromPBDMouth","RectFromLandmarks([31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],10)"); + Globals->abbreviations.insert("RectFromPBDJaw","RectFromLandmarks([51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67],10)"); } void finalize() const diff --git a/sdk/plugins/regions.cpp b/sdk/plugins/regions.cpp index 98c3ce9..481ac22 100644 --- a/sdk/plugins/regions.cpp +++ b/sdk/plugins/regions.cpp @@ -156,11 +156,13 @@ class RectFromLandmarksTransform : public UntrainableTransform maxX = maxY = -std::numeric_limits::max(); foreach(int index, indices) { - if (src.file.landmarks()[index].x() < minX) minX = src.file.landmarks()[index].x(); - if (src.file.landmarks()[index].x() > maxX) maxX = src.file.landmarks()[index].x(); - if (src.file.landmarks()[index].y() < minY) minY = src.file.landmarks()[index].y(); - if (src.file.landmarks()[index].y() > maxY) maxY = src.file.landmarks()[index].y(); - dst.file.appendLandmark(src.file.landmarks()[index]); + if (src.file.landmarks().size() < index+1) { + if (src.file.landmarks()[index].x() < minX) minX = src.file.landmarks()[index].x(); + if (src.file.landmarks()[index].x() > maxX) maxX = src.file.landmarks()[index].x(); + if (src.file.landmarks()[index].y() < minY) minY = src.file.landmarks()[index].y(); + if (src.file.landmarks()[index].y() > maxY) maxY = src.file.landmarks()[index].y(); + dst.file.appendLandmark(src.file.landmarks()[index]); + } } double width = maxX-minX+padding; diff --git a/sdk/plugins/stasm.cmake b/sdk/plugins/stasm.cmake new file mode 100644 index 0000000..0975003 --- /dev/null +++ b/sdk/plugins/stasm.cmake @@ -0,0 +1,15 @@ +set(BR_WITH_STASM OFF CACHE BOOL "Build with Stasm") + +if(${BR_WITH_STASM}) + find_package(Stasm REQUIRED) + set(BR_THIRDPARTY_SRC ${BR_THIRDPARTY_SRC} plugins/stasm.cpp) + set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Stasm_LIBS}) + + if(WIN32) + install(DIRECTORY ${Stasm_DIR}/lib/ DESTINATION bin) + else() + install(DIRECTORY ${Stasm_DIR}/lib/ DESTINATION lib) + endif() + + install(DIRECTORY ${Stasm_DIR}/models/ DESTINATION share/openbr/models/stasm) +endif() diff --git a/sdk/plugins/stasm.cpp b/sdk/plugins/stasm.cpp new file mode 100644 index 0000000..fac064a --- /dev/null +++ b/sdk/plugins/stasm.cpp @@ -0,0 +1,62 @@ +#include +#include +#include + +using namespace cv; + +namespace br +{ + +/*! + * \ingroup initializers + * \brief Initialize Stasm + * \author Scott Klum \cite sklum + */ +class StasmInitializer : public Initializer +{ + Q_OBJECT + + void initialize() const + { + Globals->abbreviations.insert("RectFromStasmEyes","RectFromLandmarks([27, 28, 29, 30, 31, 32, 33, 34, 35, 36],10)"); + Globals->abbreviations.insert("RectFromStasmJaw","RectFromLandmarks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],10)"); + Globals->abbreviations.insert("RectFromStasmBrow","RectFromLandmarks([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],10)"); + Globals->abbreviations.insert("RectFromStasmNose","RectFromLandmarks([37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47],10)"); + Globals->abbreviations.insert("RectFromStasmMouth","RectFromLandmarks([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66],10)"); + } +}; + +BR_REGISTER(Initializer, StasmInitializer) + +/*! + * \ingroup transforms + * \brief Wraps STASM key point detector + * \author Scott Klum \cite sklum + */ + +class StasmTransform : public UntrainableTransform +{ + Q_OBJECT + + void project(const Template &src, Template &dst) const + { + int nlandmarks; + int landmarks[500]; + + AsmSearchDll(&nlandmarks, landmarks, + qPrintable(src.file.name), reinterpret_cast(src.m().data), src.m().cols, src.m().rows, + src.m(), (src.m().channels() == 3), qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/mu-68-1d.conf"), qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/mu-76-2d.conf")); + + if (nlandmarks == 0) qWarning("Unable to detect Stasm landmarks"); + + dst = src; + for (int i = 0; i < nlandmarks; i++) + dst.file.appendLandmark(QPointF(landmarks[2 * i], landmarks[2 * i + 1])); + } +}; + +BR_REGISTER(Transform, StasmTransform) + +} // namespace br + +#include "stasm.moc" diff --git a/share/openbr/cmake/FindPBD.cmake b/share/openbr/cmake/FindPBD.cmake index e116db2..e2044f9 100644 --- a/share/openbr/cmake/FindPBD.cmake +++ b/share/openbr/cmake/FindPBD.cmake @@ -13,8 +13,6 @@ include_directories(${PBD_DIR}/include) link_directories(${PBD_DIR}/lib) find_package(Boost COMPONENTS system serialization REQUIRED) -message(${Boost_INCLUDE_DIR}) -message(${Boost_LIBRARIES}) include_directories(${Boost_INCLUDE_DIR}) link_directories(${Boost_LIBRARY_DIRS}) set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Boost_LIBRARIES}) diff --git a/share/openbr/cmake/FindStasm.cmake b/share/openbr/cmake/FindStasm.cmake new file mode 100644 index 0000000..5c12554 --- /dev/null +++ b/share/openbr/cmake/FindStasm.cmake @@ -0,0 +1,16 @@ +# ================================================================ +# The Stasm CMake configuration file +# +# Usage from an external project: +# In your CMakeLists.txt, add these lines: +# +# find_package(Stasm REQUIRED) +# target_link_libraries(MY_TARGET ${Stasm_LIBS}) +# ================================================================ + +find_path(Stasm_DIR include/stasm.hpp ${CMAKE_SOURCE_DIR}/3rdparty/*) + +include_directories(${Stasm_DIR}/include) +link_directories(${Stasm_DIR}/lib) + +set(Stasm_LIBS stasm)