Commit f9adb23cf372aefeed1f556c1e3cbaa29e83001b
1 parent
4a896b66
Add a bool option to StasmTransform allowing output in the stasm3 points format
Showing
1 changed file
with
10 additions
and
1 deletions
openbr/plugins/stasm4.cpp
| ... | ... | @@ -54,6 +54,9 @@ class StasmTransform : public UntrainableTransform |
| 54 | 54 | { |
| 55 | 55 | Q_OBJECT |
| 56 | 56 | |
| 57 | + Q_PROPERTY(bool stasm3Format READ get_stasm3Format WRITE set_stasm3Format RESET reset_stasm3Format STORED false) | |
| 58 | + BR_PROPERTY(bool, stasm3Format, false) | |
| 59 | + | |
| 57 | 60 | Resource<StasmCascadeClassifier> stasmCascadeResource; |
| 58 | 61 | |
| 59 | 62 | void init() |
| ... | ... | @@ -69,14 +72,20 @@ class StasmTransform : public UntrainableTransform |
| 69 | 72 | StasmCascadeClassifier *stasmCascade = stasmCascadeResource.acquire(); |
| 70 | 73 | |
| 71 | 74 | int foundface; |
| 75 | + int nLandmarks = stasm_NLANDMARKS; | |
| 72 | 76 | float landmarks[2 * stasm_NLANDMARKS]; |
| 73 | 77 | stasm_search_single(&foundface, landmarks, reinterpret_cast<const char*>(src.m().data), src.m().cols, src.m().rows, *stasmCascade, NULL, NULL); |
| 74 | 78 | |
| 79 | + if (stasm3Format) { | |
| 80 | + nLandmarks = 76; | |
| 81 | + stasm_convert_shape(landmarks, nLandmarks); | |
| 82 | + } | |
| 83 | + | |
| 75 | 84 | stasmCascadeResource.release(stasmCascade); |
| 76 | 85 | |
| 77 | 86 | if (!foundface) qWarning("No face found in %s", qPrintable(src.file.fileName())); |
| 78 | 87 | else { |
| 79 | - for (int i = 0; i < stasm_NLANDMARKS; i++) | |
| 88 | + for (int i = 0; i < nLandmarks; i++) | |
| 80 | 89 | dst.file.appendPoint(QPointF(landmarks[2 * i], landmarks[2 * i + 1])); |
| 81 | 90 | } |
| 82 | 91 | ... | ... |