diff --git a/openbr/plugins/draw.cpp b/openbr/plugins/draw.cpp index 6d20b17..9fe401f 100644 --- a/openbr/plugins/draw.cpp +++ b/openbr/plugins/draw.cpp @@ -41,7 +41,7 @@ class DrawTransform : public UntrainableTransform void project(const Template &src, Template &dst) const { const Scalar color(0,255,0); - const Scalar verboseColor(255, 255, 0); + const Scalar verboseColor(0, 0, 0); dst = src.m().clone(); if (points) { diff --git a/openbr/plugins/stasm3.cmake b/openbr/plugins/stasm3.cmake index d5636f4..8e2fd52 100644 --- a/openbr/plugins/stasm3.cmake +++ b/openbr/plugins/stasm3.cmake @@ -1,9 +1,9 @@ -set(BR_WITH_STASM OFF CACHE BOOL "Build with Stasm") +set(BR_WITH_STASM3 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(${BR_WITH_STASM3}) + find_package(Stasm3 REQUIRED) + set(BR_THIRDPARTY_SRC ${BR_THIRDPARTY_SRC} plugins/stasm3.cpp) + set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Stasm3_LIBS}) if(WIN32) install(DIRECTORY ${Stasm_DIR}/build/ DESTINATION bin) diff --git a/openbr/plugins/stasm4.cmake b/openbr/plugins/stasm4.cmake index d5636f4..f0a4a95 100644 --- a/openbr/plugins/stasm4.cmake +++ b/openbr/plugins/stasm4.cmake @@ -1,9 +1,9 @@ -set(BR_WITH_STASM OFF CACHE BOOL "Build with Stasm") +set(BR_WITH_STASM4 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(${BR_WITH_STASM4}) + find_package(Stasm4 REQUIRED) + set(BR_THIRDPARTY_SRC ${BR_THIRDPARTY_SRC} plugins/stasm4.cpp) + set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Stasm4_LIBS}) if(WIN32) install(DIRECTORY ${Stasm_DIR}/build/ DESTINATION bin) @@ -11,5 +11,5 @@ if(${BR_WITH_STASM}) install(DIRECTORY ${Stasm_DIR}/build/ DESTINATION lib) endif() - install(DIRECTORY ${Stasm_DIR}/models/ DESTINATION share/openbr/models/stasm) + #install(DIRECTORY ${Stasm_DIR}/models/ DESTINATION share/openbr/models/stasm) endif() diff --git a/openbr/plugins/stasm.cpp b/openbr/plugins/stasm4.cpp index a3eb4af..2f42c8f 100644 --- a/openbr/plugins/stasm.cpp +++ b/openbr/plugins/stasm4.cpp @@ -1,5 +1,4 @@ -#include -#include +#include #include #include "openbr_internal.h" @@ -22,7 +21,7 @@ class StasmInitializer : public Initializer Globals->abbreviations.insert("RectFromStasmEyes","RectFromPoints([27, 28, 29, 30, 31, 32, 33, 34, 35, 36],0.125,6.0)+Resize(44,164)"); Globals->abbreviations.insert("RectFromStasmJaw","RectFromPoints([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],10)"); Globals->abbreviations.insert("RectFromStasmBrow","RectFromPoints([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],0.15,6)+Resize(28,132)"); - Globals->abbreviations.insert("RectFromStasmNose","RectFromPoints([38, 39, 40, 41, 42, 43, 44, 67],0.15,1.25)+Resize(44,44)"); + Globals->abbreviations.insert("RectFromStasmNose","RectFromPoints([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58],0.15,1.25)+Resize(44,44)"); Globals->abbreviations.insert("RectFromStasmMouth","RectFromPoints([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66],0.3,3.0)+Resize(28,68)"); } }; @@ -38,45 +37,26 @@ class StasmTransform : public UntrainableTransform { Q_OBJECT - QList models; - //mutable QMutex mutex; + //QList models; + mutable QMutex mutex; void init() { - models = nInitAsmModels(qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/mu-68-1d.conf"), qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/mu-76-2d.conf")); + } void project(const Template &src, Template &dst) const { - //QMutexLocker locker(&mutex); - - //qDebug() << "PittPatt X: " << src.file.get("Affine_0").x() - src.m().cols/2 << src.file.get("Affine_1").x() - src.m().cols/2; - //qDebug() << "PittPatt Y: " << src.m().rows/2 - src.file.get("Affine_0").y() << src.m().rows/2 - src.file.get("Affine_1").y(); - - qDebug() << src.file.fileName(); + QMutexLocker locker(&mutex); - int numLandmarks; - int landmarks[500]; + int foundface; + float landmarks[2 * stasm_NLANDMARKS]; // x,y coords (note the 2) + stasm_search_single(&foundface, landmarks, reinterpret_cast(src.m().data), src.m().cols, src.m().rows, NULL, "/Users/scottklum/openbr/3rdparty/stasm4.0.0/data"); - DET_PARAMS parameters; - parameters.lex = src.file.get("Affine_0").x() - src.m().cols/2; - parameters.ley = src.m().rows/2 - src.file.get("Affine_0").y(); - parameters.rex = src.file.get("Affine_1").x() - src.m().cols/2; - parameters.rey = src.m().rows/2 - src.file.get("Affine_1").y(); - - AsmSearchDll(numLandmarks, landmarks, qPrintable(src.file.name), - reinterpret_cast(src.m().data), src.m(), models, - qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/"), - parameters); - - if (numLandmarks == 0) { - qWarning("Unable to detect Stasm landmarks for %s", qPrintable(src.file.fileName())); - dst.file.set("FTE", true); - dst.m() = src.m(); - return; - } + if (!foundface) + qDebug() << "No face found in " << qPrintable("/Users/scottklum/facesketchid/data/img/" + src.file.path() + "/" + src.file.fileName()); - for (int i = 0; i < numLandmarks; i++) { + for (int i = 0; i < stasm_NLANDMARKS; i++) { dst.file.appendPoint(QPointF(landmarks[2 * i], landmarks[2 * i + 1])); } @@ -88,4 +68,4 @@ BR_REGISTER(Transform, StasmTransform) } // namespace br -#include "stasm.moc" +#include "stasm4.moc" diff --git a/share/openbr/cmake/FindStasm3.cmake b/share/openbr/cmake/FindStasm3.cmake index 4fb4b9d..4ccac5c 100644 --- a/share/openbr/cmake/FindStasm3.cmake +++ b/share/openbr/cmake/FindStasm3.cmake @@ -5,7 +5,7 @@ # In your CMakeLists.txt, add these lines: # # find_package(Stasm3 REQUIRED) -# target_link_libraries(MY_TARGET ${Stasm_LIBS}) +# target_link_libraries(MY_TARGET ${Stasm4_LIBS}) # ================================================================ find_path(Stasm_DIR include/stasm.hpp ${CMAKE_SOURCE_DIR}/3rdparty/*) @@ -17,4 +17,4 @@ set(SRC ${SOURCE};${SRC}) include_directories(${Stasm_DIR}/include) link_directories(${Stasm_DIR}/build) -set(Stasm_LIBS stasm) +set(Stasm3_LIBS stasm) diff --git a/share/openbr/cmake/FindStasm4.cmake b/share/openbr/cmake/FindStasm4.cmake index 2a3b39c..43fda3b 100644 --- a/share/openbr/cmake/FindStasm4.cmake +++ b/share/openbr/cmake/FindStasm4.cmake @@ -5,16 +5,16 @@ # In your CMakeLists.txt, add these lines: # # find_package(Stasm4 REQUIRED) -# target_link_libraries(MY_TARGET ${Stasm_LIBS}) +# target_link_libraries(MY_TARGET ${Stasm4_LIBS}) # ================================================================ -find_path(Stasm_DIR include/stasm.hpp ${CMAKE_SOURCE_DIR}/3rdparty/*) +find_path(Stasm_DIR stasm/stasm_lib.h ${CMAKE_SOURCE_DIR}/3rdparty/*) add_subdirectory(${Stasm_DIR} ${Stasm_DIR}/build) set(SRC ${SOURCE};${SRC}) -include_directories(${Stasm_DIR}/include) +include_directories(${Stasm_DIR}/stasm) link_directories(${Stasm_DIR}/build) -set(Stasm_LIBS stasm) +set(Stasm4_LIBS stasm)