Commit 886a0abc7d35b5b979d255f391b099932aff53c3
1 parent
f1ce81bd
fixed enroll
Showing
5 changed files
with
73 additions
and
1 deletions
sdk/core/core.cpp
| ... | ... | @@ -132,7 +132,15 @@ struct AlgorithmCore |
| 132 | 132 | if (data.isEmpty()) break; |
| 133 | 133 | const int numFiles = data.size(); |
| 134 | 134 | |
| 135 | - data >> *transform; | |
| 135 | + if (!Globals->backProject){ | |
| 136 | + data >> *transform; | |
| 137 | + } else { | |
| 138 | + // I don't really know if this makes sense. | |
| 139 | + //TemplateList dst; | |
| 140 | + transform->backProject(data, data); | |
| 141 | + //data = dst; | |
| 142 | + } | |
| 143 | + | |
| 136 | 144 | g->writeBlock(data); |
| 137 | 145 | const FileList newFiles = data.files(); |
| 138 | 146 | fileList.append(newFiles); | ... | ... |
sdk/openbr_plugin.cpp
| ... | ... | @@ -1144,6 +1144,18 @@ static void _project(const Transform *transform, const Template *src, Template * |
| 1144 | 1144 | } |
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | +static void _backProject(const Transform *transform, const Template *dst, Template *src) | |
| 1148 | +{ | |
| 1149 | + try { | |
| 1150 | + transform->backProject(*dst, *src); | |
| 1151 | + } catch (...) { | |
| 1152 | + qWarning("Exception triggered when processing %s with transform %s", qPrintable(src->file.flat()), qPrintable(transform->name())); | |
| 1153 | + *src = Template(dst->file); | |
| 1154 | + src->file.setBool("FTE"); | |
| 1155 | + } | |
| 1156 | +} | |
| 1157 | + | |
| 1158 | + | |
| 1147 | 1159 | void Transform::project(const TemplateList &src, TemplateList &dst) const |
| 1148 | 1160 | { |
| 1149 | 1161 | dst.reserve(src.size()); |
| ... | ... | @@ -1162,6 +1174,18 @@ void Transform::backProject(const Template &dst, Template &src) const |
| 1162 | 1174 | src = dst; |
| 1163 | 1175 | } |
| 1164 | 1176 | |
| 1177 | +void Transform::backProject(const TemplateList &dst, TemplateList &src) const | |
| 1178 | +{ | |
| 1179 | + src.reserve(dst.size()); | |
| 1180 | + for (int i=0; i<dst.size(); i++) src.append(Template()); | |
| 1181 | + | |
| 1182 | + QList< QFuture<void> > futures; | |
| 1183 | + if (Globals->parallelism) futures.reserve(dst.size()); | |
| 1184 | + for (int i=0; i<dst.size(); i++) | |
| 1185 | + if (Globals->parallelism) futures.append(QtConcurrent::run(_backProject, this, &dst[i], &src[i])); | |
| 1186 | + else _backProject (this, &dst[i], &src[i]); | |
| 1187 | + if (Globals->parallelism) Globals->trackFutures(futures); | |
| 1188 | +} | |
| 1165 | 1189 | |
| 1166 | 1190 | /* Distance - public methods */ |
| 1167 | 1191 | void Distance::train(const TemplateList &templates) | ... | ... |
sdk/openbr_plugin.h
| ... | ... | @@ -913,6 +913,7 @@ public: |
| 913 | 913 | virtual void project(const Template &src, Template &dst) const = 0; /*!< \brief Apply the transform. */ |
| 914 | 914 | virtual void project(const TemplateList &src, TemplateList &dst) const; /*!< \brief Apply the transform. */ |
| 915 | 915 | virtual void backProject(const Template &dst, Template &src) const; /*!< \brief Invert the transform. */ |
| 916 | + virtual void backProject(const TemplateList &dst, TemplateList &src) const; /*!< \brief Invert the transform. */ | |
| 916 | 917 | |
| 917 | 918 | |
| 918 | 919 | ... | ... |
sdk/plugins/eigen3.cpp
| ... | ... | @@ -52,6 +52,7 @@ public: |
| 52 | 52 | PCA() : keep(0.95), drop(0), whiten(false) {} |
| 53 | 53 | |
| 54 | 54 | private: |
| 55 | + /* | |
| 55 | 56 | void backProject(const Template &src, Template &dst) const |
| 56 | 57 | { |
| 57 | 58 | const cv::Mat &m = src; |
| ... | ... | @@ -64,6 +65,7 @@ private: |
| 64 | 65 | // Do projection |
| 65 | 66 | outMap = (eVecs * inMap) + mean; |
| 66 | 67 | } |
| 68 | + */ | |
| 67 | 69 | |
| 68 | 70 | double residualReconstructionError(const Template &src) const |
| 69 | 71 | { | ... | ... |
sdk/plugins/meta.cpp
| ... | ... | @@ -136,6 +136,25 @@ class PipeTransform : public MetaTransform |
| 136 | 136 | Transform::project(src, dst); |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | + | |
| 140 | + void projectBack(const Template &dst, Template &src) const | |
| 141 | + { | |
| 142 | + src = dst; | |
| 143 | + //reverse order in which transforms are processed | |
| 144 | + int length = transforms.length(); | |
| 145 | + //foreach (const Transform *f, transforms) { | |
| 146 | + for (int i = 0; i < length; i++){ | |
| 147 | + Transform *f = transforms.at(length - i - 1); | |
| 148 | + try { | |
| 149 | + src >> *f; | |
| 150 | + } catch (...) { | |
| 151 | + qWarning("Exception triggered when processing %s with transform %s", qPrintable(dst.file.flat()), qPrintable(f->name())); | |
| 152 | + src = Template(src.file); | |
| 153 | + src.file.setBool("FTE"); | |
| 154 | + } | |
| 155 | + } | |
| 156 | + } | |
| 157 | + | |
| 139 | 158 | }; |
| 140 | 159 | |
| 141 | 160 | BR_REGISTER(Transform, PipeTransform) |
| ... | ... | @@ -193,6 +212,24 @@ class ChainTransform : public MetaTransform |
| 193 | 212 | dst = Simplified(dst); |
| 194 | 213 | } |
| 195 | 214 | } |
| 215 | + | |
| 216 | + void projectBack(const Template &dst, Template &src) const | |
| 217 | + { | |
| 218 | + src = dst; | |
| 219 | + //reverse order in which transforms are processed | |
| 220 | + int length = transforms.length(); | |
| 221 | + //foreach (const Transform *f, transforms) { | |
| 222 | + for (int i = 0; i < length; i++){ | |
| 223 | + Transform *f = transforms.at(length - i - 1); | |
| 224 | + try { | |
| 225 | + src >> *f; | |
| 226 | + } catch (...) { | |
| 227 | + qWarning("Exception triggered when processing %s with transform %s", qPrintable(dst.file.flat()), qPrintable(f->name())); | |
| 228 | + src = Template(src.file); | |
| 229 | + src.file.setBool("FTE"); | |
| 230 | + } | |
| 231 | + } | |
| 232 | + } | |
| 196 | 233 | }; |
| 197 | 234 | |
| 198 | 235 | BR_REGISTER(Transform, ChainTransform) | ... | ... |