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