Commit f74da8ddc6714635b1d5604587abbff3d7a2f413
1 parent
cb9e7362
added CheckTransform
Showing
1 changed file
with
26 additions
and
0 deletions
sdk/plugins/misc.cpp
| ... | ... | @@ -117,6 +117,32 @@ BR_REGISTER(Transform, PrintTransform) |
| 117 | 117 | |
| 118 | 118 | /*! |
| 119 | 119 | * \ingroup transforms |
| 120 | + * \brief Checks the template for NaN values. | |
| 121 | + * \author Josh Klontz \cite jklontz | |
| 122 | + */ | |
| 123 | +class CheckTransform : public UntrainableMetaTransform | |
| 124 | +{ | |
| 125 | + Q_OBJECT | |
| 126 | + | |
| 127 | + void project(const Template &src, Template &dst) const | |
| 128 | + { | |
| 129 | + dst = src; | |
| 130 | + foreach (const Mat &m, src) { | |
| 131 | + Mat fm; | |
| 132 | + m.convertTo(fm, CV_32F); | |
| 133 | + const int elements = fm.rows * fm.cols * fm.channels(); | |
| 134 | + const float *data = (const float*)fm.data; | |
| 135 | + for (int i=0; i<elements; i++) | |
| 136 | + if (data[i] != data[i]) | |
| 137 | + qFatal("%s NaN check failed!", qPrintable(src.file.flat())); | |
| 138 | + } | |
| 139 | + } | |
| 140 | +}; | |
| 141 | + | |
| 142 | +BR_REGISTER(Transform, CheckTransform) | |
| 143 | + | |
| 144 | +/*! | |
| 145 | + * \ingroup transforms | |
| 120 | 146 | * \brief Sets the template's matrix data to the br::File::name. |
| 121 | 147 | * \author Josh Klontz \cite jklontz |
| 122 | 148 | */ | ... | ... |