Commit ba990be3a12a110097ce6bf2430b920446b8ec13

Authored by Charles Otto
1 parent bc16c3dd

Move some functionality from openbr_plugin.h to openbr_internal.h

Move CompositeTransform, and several other categorical abstract transform types
to a new file, openbr_internal.h. Adjust files in plugins to include the new
file rather than incldue openbr_plugin.h directly.
openbr/frvt2012.cpp
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <openbr/openbr_plugin.h> 17 #include <openbr/openbr_plugin.h>
  18 +#include <openbr/plugins/openbr_internal.h>
18 19
19 #include "frvt2012.h" 20 #include "frvt2012.h"
20 #include "core/distance_sse.h" 21 #include "core/distance_sse.h"
openbr/openbr_plugin.cpp
@@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
25 #include <algorithm> 25 #include <algorithm>
26 #include <iostream> 26 #include <iostream>
27 #include <openbr/openbr_plugin.h> 27 #include <openbr/openbr_plugin.h>
  28 +#include <openbr/plugins/openbr_internal.h>
28 29
29 #ifndef BR_EMBEDDED 30 #ifndef BR_EMBEDDED
30 #include <QApplication> 31 #include <QApplication>
openbr/openbr_plugin.h
@@ -1127,171 +1127,6 @@ inline QDataStream &amp;operator&gt;&gt;(QDataStream &amp;stream, Transform &amp;f) @@ -1127,171 +1127,6 @@ inline QDataStream &amp;operator&gt;&gt;(QDataStream &amp;stream, Transform &amp;f)
1127 f.load(stream); 1127 f.load(stream);
1128 return stream; 1128 return stream;
1129 } 1129 }
1130 -  
1131 -/*!  
1132 - * \brief A br::Transform for which the results of project may change due to prior calls to project  
1133 - */  
1134 -class BR_EXPORT TimeVaryingTransform : public Transform  
1135 -{  
1136 - Q_OBJECT  
1137 -  
1138 -public:  
1139 - virtual bool timeVarying() const { return true; }  
1140 -  
1141 - virtual void project(const Template &src, Template &dst) const  
1142 - {  
1143 - qFatal("No const project defined for time-varying transform");  
1144 - (void) dst; (void) src;  
1145 - }  
1146 -  
1147 - virtual void project(const TemplateList &src, TemplateList &dst) const  
1148 - {  
1149 - qFatal("No const project defined for time-varying transform");  
1150 - (void) dst; (void) src;  
1151 - }  
1152 -  
1153 - // Get a compile failure if this isn't here to go along with the other  
1154 - // projectUpdate, no idea why  
1155 - virtual void projectUpdate(const Template & src, Template & dst)  
1156 - {  
1157 - (void) src; (void) dst;  
1158 - qFatal("do something useful");  
1159 - }  
1160 -  
1161 - virtual void projectUpdate(const TemplateList &src, TemplateList &dst)  
1162 - {  
1163 - foreach (const Template & src_part, src) {  
1164 - Template out;  
1165 - projectUpdate(src_part, out);  
1166 - dst.append(out);  
1167 - }  
1168 - }  
1169 -  
1170 - virtual Transform * pseudoCopy()  
1171 - {  
1172 - return this->clone();  
1173 - }  
1174 -  
1175 -  
1176 -protected:  
1177 - TimeVaryingTransform(bool independent = true, bool trainable = true) : Transform(independent, trainable) {}  
1178 -};  
1179 -  
1180 -/*!  
1181 - * \brief A br::Transform expecting multiple matrices per template.  
1182 - */  
1183 -class BR_EXPORT MetaTransform : public Transform  
1184 -{  
1185 - Q_OBJECT  
1186 -  
1187 -protected:  
1188 - MetaTransform() : Transform(false) {}  
1189 -};  
1190 -  
1191 -/*!  
1192 - * \brief A br::Transform that does not require training data.  
1193 - */  
1194 -class BR_EXPORT UntrainableTransform : public Transform  
1195 -{  
1196 - Q_OBJECT  
1197 -  
1198 -protected:  
1199 - UntrainableTransform(bool independent = true) : Transform(independent, false) {} /*!< \brief Construct an untrainable transform. */  
1200 -  
1201 -private:  
1202 - Transform *clone() const { return const_cast<UntrainableTransform*>(this); }  
1203 - void train(const TemplateList &data) { (void) data; }  
1204 - void store(QDataStream &stream) const { (void) stream; }  
1205 - void load(QDataStream &stream) { (void) stream; }  
1206 -};  
1207 -  
1208 -/*!  
1209 - * \brief A br::MetaTransform that does not require training data.  
1210 - */  
1211 -class BR_EXPORT UntrainableMetaTransform : public UntrainableTransform  
1212 -{  
1213 - Q_OBJECT  
1214 -  
1215 -protected:  
1216 - UntrainableMetaTransform() : UntrainableTransform(false) {}  
1217 -};  
1218 -  
1219 -/*!  
1220 - * \brief A MetaTransform that aggregates some sub-transforms  
1221 - */  
1222 -class BR_EXPORT CompositeTransform : public TimeVaryingTransform  
1223 -{  
1224 - Q_OBJECT  
1225 -  
1226 -public:  
1227 - Q_PROPERTY(QList<br::Transform*> transforms READ get_transforms WRITE set_transforms RESET reset_transforms)  
1228 - BR_PROPERTY(QList<br::Transform*>, transforms, QList<br::Transform*>())  
1229 -  
1230 - virtual void project(const Template &src, Template &dst) const  
1231 - {  
1232 - if (timeVarying()) qFatal("No const project defined for time-varying transform");  
1233 - _project(src, dst);  
1234 - }  
1235 -  
1236 - virtual void project(const TemplateList &src, TemplateList &dst) const  
1237 - {  
1238 - if (timeVarying()) qFatal("No const project defined for time-varying transform");  
1239 - _project(src, dst);  
1240 - }  
1241 -  
1242 - bool timeVarying() const { return isTimeVarying; }  
1243 -  
1244 - void init()  
1245 - {  
1246 - isTimeVarying = false;  
1247 - trainable = false;  
1248 - foreach (const br::Transform *transform, transforms) {  
1249 - isTimeVarying = isTimeVarying || transform->timeVarying();  
1250 - trainable = trainable || transform->trainable;  
1251 - }  
1252 - }  
1253 -  
1254 - Transform * pseudoCopy()  
1255 - {  
1256 - if (!timeVarying())  
1257 - return this;  
1258 -  
1259 - QString name = metaObject()->className();  
1260 - name.replace("Transform","");  
1261 - name += "([])";  
1262 - name.replace("br::","");  
1263 - CompositeTransform * output = dynamic_cast<CompositeTransform *>(Transform::make(name, NULL));  
1264 -  
1265 - if (output == NULL)  
1266 - qFatal("Dynamic cast failed!");  
1267 -  
1268 - foreach(Transform* t, transforms )  
1269 - {  
1270 - Transform * maybe_copy = t->pseudoCopy();  
1271 - if (maybe_copy->parent() == NULL)  
1272 - maybe_copy->setParent(output);  
1273 - output->transforms.append(t->pseudoCopy());  
1274 - }  
1275 -  
1276 - output->file = this->file;  
1277 - output->classes = classes;  
1278 - output->instances = instances;  
1279 - output->fraction = fraction;  
1280 -  
1281 - output->init();  
1282 -  
1283 - return output;  
1284 - }  
1285 -  
1286 -protected:  
1287 - bool isTimeVarying;  
1288 -  
1289 - virtual void _project(const Template & src, Template & dst) const = 0;  
1290 - virtual void _project(const TemplateList & src, TemplateList & dst) const = 0;  
1291 -  
1292 - CompositeTransform() : TimeVaryingTransform(false) {}  
1293 -};  
1294 -  
1295 /*! @}*/ 1130 /*! @}*/
1296 1131
1297 /*! 1132 /*!
openbr/plugins/algorithms.cpp
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 * limitations under the License. * 14 * limitations under the License. *
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 -#include <openbr/openbr_plugin.h> 17 +#include "openbr_internal.h"
18 18
19 namespace br 19 namespace br
20 { 20 {
openbr/plugins/cascade.cpp
@@ -15,8 +15,7 @@ @@ -15,8 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/objdetect/objdetect.hpp> 17 #include <opencv2/objdetect/objdetect.hpp>
18 -#include <openbr/openbr_plugin.h>  
19 - 18 +#include "openbr_internal.h"
20 #include "openbr/core/opencvutils.h" 19 #include "openbr/core/opencvutils.h"
21 #include "openbr/core/resource.h" 20 #include "openbr/core/resource.h"
22 21
openbr/plugins/cluster.cpp
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 * limitations under the License. * 14 * limitations under the License. *
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 -#include <openbr/openbr_plugin.h> 17 +#include "openbr_internal.h"
18 #include <opencv2/flann/flann.hpp> 18 #include <opencv2/flann/flann.hpp>
19 19
20 #include "openbr/core/opencvutils.h" 20 #include "openbr/core/opencvutils.h"
openbr/plugins/crop.cpp
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 -#include <openbr/openbr_plugin.h> 18 +#include "openbr_internal.h"
19 19
20 #include "openbr/core/opencvutils.h" 20 #include "openbr/core/opencvutils.h"
21 21
openbr/plugins/ct8.cpp
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 #include <exception> 11 #include <exception>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 -#include <openbr/openbr_plugin.h> 14 +#include "openbr_internal.h"
15 15
16 #include "core/resource.h" 16 #include "core/resource.h"
17 17
openbr/plugins/cvt.cpp
@@ -15,8 +15,7 @@ @@ -15,8 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 -#include <openbr/openbr_plugin.h>  
19 - 18 +#include "openbr_internal.h"
20 #include "openbr/core/opencvutils.h" 19 #include "openbr/core/opencvutils.h"
21 20
22 using namespace cv; 21 using namespace cv;
openbr/plugins/denoising.cpp
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/photo/photo.hpp> 17 #include <opencv2/photo/photo.hpp>
18 -#include <openbr/openbr_plugin.h> 18 +#include "openbr_internal.h"
19 19
20 using namespace cv; 20 using namespace cv;
21 21
openbr/plugins/distance.cpp
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 #include <QFutureSynchronizer> 17 #include <QFutureSynchronizer>
18 #include <QtConcurrentRun> 18 #include <QtConcurrentRun>
19 #include <opencv2/imgproc/imgproc.hpp> 19 #include <opencv2/imgproc/imgproc.hpp>
20 -#include <openbr/openbr_plugin.h> 20 +#include "openbr_internal.h"
21 21
22 #include "openbr/core/distance_sse.h" 22 #include "openbr/core/distance_sse.h"
23 #include "openbr/core/qtutils.h" 23 #include "openbr/core/qtutils.h"
openbr/plugins/draw.cpp
@@ -15,8 +15,7 @@ @@ -15,8 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/highgui/highgui.hpp> 17 #include <opencv2/highgui/highgui.hpp>
18 -#include <openbr/openbr_plugin.h>  
19 - 18 +#include "openbr_internal.h"
20 #include "openbr/core/opencvutils.h" 19 #include "openbr/core/opencvutils.h"
21 20
22 using namespace cv; 21 using namespace cv;
openbr/plugins/eigen3.cpp
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <Eigen/Dense> 17 #include <Eigen/Dense>
18 -#include <openbr/openbr_plugin.h> 18 +#include "openbr_internal.h"
19 19
20 #include "openbr/core/common.h" 20 #include "openbr/core/common.h"
21 #include "openbr/core/eigenutils.h" 21 #include "openbr/core/eigenutils.h"
openbr/plugins/eyes.cpp
@@ -34,8 +34,7 @@ @@ -34,8 +34,7 @@
34 */ 34 */
35 35
36 #include <opencv2/imgproc/imgproc.hpp> 36 #include <opencv2/imgproc/imgproc.hpp>
37 -#include <openbr/openbr_plugin.h>  
38 - 37 +#include "openbr_internal.h"
39 #include "openbr/core/opencvutils.h" 38 #include "openbr/core/opencvutils.h"
40 39
41 using namespace cv; 40 using namespace cv;
openbr/plugins/fill.cpp
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/photo/photo.hpp> 17 #include <opencv2/photo/photo.hpp>
18 -#include <openbr/openbr_plugin.h> 18 +#include "openbr_internal.h"
19 19
20 using namespace cv; 20 using namespace cv;
21 21
openbr/plugins/filter.cpp
@@ -15,8 +15,7 @@ @@ -15,8 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 -#include <openbr/openbr_plugin.h>  
19 - 18 +#include "openbr_internal.h"
20 #include "openbr/core/tanh_sse.h" 19 #include "openbr/core/tanh_sse.h"
21 20
22 using namespace cv; 21 using namespace cv;
openbr/plugins/format.cpp
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 #include <QtXml> 19 #include <QtXml>
20 #endif // BR_EMBEDDED 20 #endif // BR_EMBEDDED
21 #include <opencv2/highgui/highgui.hpp> 21 #include <opencv2/highgui/highgui.hpp>
22 -#include <openbr/openbr_plugin.h> 22 +#include "openbr_internal.h"
23 23
24 #include "openbr/core/bee.h" 24 #include "openbr/core/bee.h"
25 #include "openbr/core/opencvutils.h" 25 #include "openbr/core/opencvutils.h"
openbr/plugins/gallery.cpp
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 #include <QSqlRecord> 24 #include <QSqlRecord>
25 #endif // BR_EMBEDDED 25 #endif // BR_EMBEDDED
26 #include <opencv2/highgui/highgui.hpp> 26 #include <opencv2/highgui/highgui.hpp>
27 -#include <openbr/openbr_plugin.h> 27 +#include "openbr_internal.h"
28 28
29 #include "NaturalStringCompare.h" 29 #include "NaturalStringCompare.h"
30 #include "openbr/core/bee.h" 30 #include "openbr/core/bee.h"
openbr/plugins/gui.cpp
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 #include <QWaitCondition> 4 #include <QWaitCondition>
5 #include <QMutex> 5 #include <QMutex>
6 #include <opencv2/imgproc/imgproc.hpp> 6 #include <opencv2/imgproc/imgproc.hpp>
7 -#include <openbr/openbr_plugin.h> 7 +#include "openbr_internal.h"
8 8
9 using namespace cv; 9 using namespace cv;
10 10
openbr/plugins/hash.cpp
@@ -15,8 +15,7 @@ @@ -15,8 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <QCryptographicHash> 17 #include <QCryptographicHash>
18 -#include <openbr/openbr_plugin.h>  
19 - 18 +#include "openbr_internal.h"
20 #include "openbr/core/qtutils.h" 19 #include "openbr/core/qtutils.h"
21 20
22 namespace br 21 namespace br
openbr/plugins/hist.cpp
@@ -15,8 +15,7 @@ @@ -15,8 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 -#include <openbr/openbr_plugin.h>  
19 - 18 +#include "openbr_internal.h"
20 #include "openbr/core/common.h" 19 #include "openbr/core/common.h"
21 #include "openbr/core/opencvutils.h" 20 #include "openbr/core/opencvutils.h"
22 21
openbr/plugins/integral.cpp
1 #include <opencv2/imgproc/imgproc.hpp> 1 #include <opencv2/imgproc/imgproc.hpp>
2 #include <Eigen/Core> 2 #include <Eigen/Core>
3 -#include <openbr/openbr_plugin.h> 3 +#include "openbr_internal.h"
4 4
5 #include "openbr/core/opencvutils.h" 5 #include "openbr/core/opencvutils.h"
6 6
openbr/plugins/ipc2013.cpp
1 -#include <openbr/openbr_plugin.h> 1 +#include "openbr_internal.h"
2 #include <pxcaccelerator.h> 2 #include <pxcaccelerator.h>
3 #include <pxcface.h> 3 #include <pxcface.h>
4 #include <pxcimage.h> 4 #include <pxcimage.h>
openbr/plugins/keypoint.cpp
@@ -16,8 +16,7 @@ @@ -16,8 +16,7 @@
16 16
17 #include <opencv2/features2d/features2d.hpp> 17 #include <opencv2/features2d/features2d.hpp>
18 #include <opencv2/nonfree/nonfree.hpp> 18 #include <opencv2/nonfree/nonfree.hpp>
19 -#include <openbr/openbr_plugin.h>  
20 - 19 +#include "openbr_internal.h"
21 #include "openbr/core/opencvutils.h" 20 #include "openbr/core/opencvutils.h"
22 21
23 using namespace cv; 22 using namespace cv;
openbr/plugins/lbp.cpp
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 #include <limits> 18 #include <limits>
19 -#include <openbr/openbr_plugin.h> 19 +#include "openbr_internal.h"
20 20
21 using namespace cv; 21 using namespace cv;
22 22
openbr/plugins/mask.cpp
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 -#include <openbr/openbr_plugin.h> 18 +#include "openbr_internal.h"
19 19
20 using namespace cv; 20 using namespace cv;
21 21
openbr/plugins/meta.cpp
@@ -16,8 +16,7 @@ @@ -16,8 +16,7 @@
16 16
17 #include <QFutureSynchronizer> 17 #include <QFutureSynchronizer>
18 #include <QtConcurrentRun> 18 #include <QtConcurrentRun>
19 -#include <openbr/openbr_plugin.h>  
20 - 19 +#include "openbr_internal.h"
21 #include "openbr/core/common.h" 20 #include "openbr/core/common.h"
22 #include "openbr/core/opencvutils.h" 21 #include "openbr/core/opencvutils.h"
23 #include "openbr/core/qtutils.h" 22 #include "openbr/core/qtutils.h"
openbr/plugins/misc.cpp
@@ -15,8 +15,7 @@ @@ -15,8 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/highgui/highgui.hpp> 17 #include <opencv2/highgui/highgui.hpp>
18 -#include <openbr/openbr_plugin.h>  
19 - 18 +#include "openbr_internal.h"
20 #include "openbr/core/opencvutils.h" 19 #include "openbr/core/opencvutils.h"
21 20
22 using namespace cv; 21 using namespace cv;
openbr/plugins/mongoose.cpp
1 -#include <openbr/openbr_plugin.h> 1 +#include "openbr_internal.h"
2 #include <mongoose.h> 2 #include <mongoose.h>
3 3
4 namespace br 4 namespace br
openbr/plugins/nec3.cpp
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 4
5 #include <NeoFacePro.h> 5 #include <NeoFacePro.h>
6 6
7 -#include <openbr/openbr_plugin.h> 7 +#include "openbr_internal.h"
8 #include "core/resource.h" 8 #include "core/resource.h"
9 9
10 using namespace br; 10 using namespace br;
openbr/plugins/neclatent1.cpp
1 -#include <openbr/openbr_plugin.h> 1 +#include "openbr_internal.h"
2 #include <LatentEFS.h> 2 #include <LatentEFS.h>
3 3
4 // Necessary to allocate a large memory though the actual template size may be much smaller 4 // Necessary to allocate a large memory though the actual template size may be much smaller
openbr/plugins/normalize.cpp
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 #include <opencv2/imgproc/imgproc.hpp> 19 #include <opencv2/imgproc/imgproc.hpp>
20 #include <opencv2/highgui/highgui.hpp> 20 #include <opencv2/highgui/highgui.hpp>
21 #include <Eigen/Core> 21 #include <Eigen/Core>
22 -#include <openbr/openbr_plugin.h> 22 +#include "openbr_internal.h"
23 23
24 #include "openbr/core/common.h" 24 #include "openbr/core/common.h"
25 #include "openbr/core/opencvutils.h" 25 #include "openbr/core/opencvutils.h"
openbr/plugins/nt4.cpp
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 #include <NMatcherParams.h> 10 #include <NMatcherParams.h>
11 #include <NTemplate.h> 11 #include <NTemplate.h>
12 #include <NLicensing.h> 12 #include <NLicensing.h>
13 -#include <openbr/openbr_plugin.h> 13 +#include "openbr_internal.h"
14 14
15 //IRIS 15 //IRIS
16 #include <NEExtractor.h> 16 #include <NEExtractor.h>
openbr/plugins/openbr_internal.h 0 โ†’ 100644
  1 +#ifndef __OPENBR_INTERNAL_H
  2 +#define __OPENBR_INTERNAL_H
  3 +
  4 +#include "openbr/openbr_plugin.h"
  5 +
  6 +namespace br
  7 +{
  8 +/*!
  9 + * \brief A br::Transform that does not require training data.
  10 + */
  11 +class BR_EXPORT UntrainableTransform : public Transform
  12 +{
  13 + Q_OBJECT
  14 +
  15 +protected:
  16 + UntrainableTransform(bool independent = true) : Transform(independent, false) {} /*!< \brief Construct an untrainable transform. */
  17 +
  18 +private:
  19 + Transform *clone() const { return const_cast<UntrainableTransform*>(this); }
  20 + void train(const TemplateList &data) { (void) data; }
  21 + void store(QDataStream &stream) const { (void) stream; }
  22 + void load(QDataStream &stream) { (void) stream; }
  23 +};
  24 +
  25 +/*!
  26 + * \brief A br::MetaTransform that does not require training data.
  27 + */
  28 +class BR_EXPORT UntrainableMetaTransform : public UntrainableTransform
  29 +{
  30 + Q_OBJECT
  31 +
  32 +protected:
  33 + UntrainableMetaTransform() : UntrainableTransform(false) {}
  34 +};
  35 +
  36 +/*!
  37 + * \brief A br::Transform for which the results of project may change due to prior calls to project
  38 + */
  39 +class BR_EXPORT TimeVaryingTransform : public Transform
  40 +{
  41 + Q_OBJECT
  42 +
  43 +public:
  44 + virtual bool timeVarying() const { return true; }
  45 +
  46 + virtual void project(const Template &src, Template &dst) const
  47 + {
  48 + qFatal("No const project defined for time-varying transform");
  49 + (void) dst; (void) src;
  50 + }
  51 +
  52 + virtual void project(const TemplateList &src, TemplateList &dst) const
  53 + {
  54 + qFatal("No const project defined for time-varying transform");
  55 + (void) dst; (void) src;
  56 + }
  57 +
  58 + // Get a compile failure if this isn't here to go along with the other
  59 + // projectUpdate, no idea why
  60 + virtual void projectUpdate(const Template & src, Template & dst)
  61 + {
  62 + (void) src; (void) dst;
  63 + qFatal("do something useful");
  64 + }
  65 +
  66 + virtual void projectUpdate(const TemplateList &src, TemplateList &dst)
  67 + {
  68 + foreach (const Template & src_part, src) {
  69 + Template out;
  70 + projectUpdate(src_part, out);
  71 + dst.append(out);
  72 + }
  73 + }
  74 +
  75 + virtual Transform * pseudoCopy()
  76 + {
  77 + return this->clone();
  78 + }
  79 +
  80 +
  81 +protected:
  82 + TimeVaryingTransform(bool independent = true, bool trainable = true) : Transform(independent, trainable) {}
  83 +};
  84 +
  85 +/*!
  86 + * \brief A br::Transform expecting multiple matrices per template.
  87 + */
  88 +class BR_EXPORT MetaTransform : public Transform
  89 +{
  90 + Q_OBJECT
  91 +
  92 +protected:
  93 + MetaTransform() : Transform(false) {}
  94 +};
  95 +
  96 +/*!
  97 + * \brief A MetaTransform that aggregates some sub-transforms
  98 + */
  99 +class BR_EXPORT CompositeTransform : public TimeVaryingTransform
  100 +{
  101 + Q_OBJECT
  102 +
  103 +public:
  104 + Q_PROPERTY(QList<br::Transform*> transforms READ get_transforms WRITE set_transforms RESET reset_transforms)
  105 + BR_PROPERTY(QList<br::Transform*>, transforms, QList<br::Transform*>())
  106 +
  107 + virtual void project(const Template &src, Template &dst) const
  108 + {
  109 + if (timeVarying()) qFatal("No const project defined for time-varying transform");
  110 + _project(src, dst);
  111 + }
  112 +
  113 + virtual void project(const TemplateList &src, TemplateList &dst) const
  114 + {
  115 + if (timeVarying()) qFatal("No const project defined for time-varying transform");
  116 + _project(src, dst);
  117 + }
  118 +
  119 + bool timeVarying() const { return isTimeVarying; }
  120 +
  121 + void init()
  122 + {
  123 + isTimeVarying = false;
  124 + trainable = false;
  125 + foreach (const br::Transform *transform, transforms) {
  126 + isTimeVarying = isTimeVarying || transform->timeVarying();
  127 + trainable = trainable || transform->trainable;
  128 + }
  129 + }
  130 +
  131 + Transform * pseudoCopy()
  132 + {
  133 + if (!timeVarying())
  134 + return this;
  135 +
  136 + QString name = metaObject()->className();
  137 + name.replace("Transform","");
  138 + name += "([])";
  139 + name.replace("br::","");
  140 + CompositeTransform * output = dynamic_cast<CompositeTransform *>(Transform::make(name, NULL));
  141 +
  142 + if (output == NULL)
  143 + qFatal("Dynamic cast failed!");
  144 +
  145 + foreach(Transform* t, transforms )
  146 + {
  147 + Transform * maybe_copy = t->pseudoCopy();
  148 + if (maybe_copy->parent() == NULL)
  149 + maybe_copy->setParent(output);
  150 + output->transforms.append(t->pseudoCopy());
  151 + }
  152 +
  153 + output->file = this->file;
  154 + output->classes = classes;
  155 + output->instances = instances;
  156 + output->fraction = fraction;
  157 +
  158 + output->init();
  159 +
  160 + return output;
  161 + }
  162 +
  163 +protected:
  164 + bool isTimeVarying;
  165 +
  166 + virtual void _project(const Template & src, Template & dst) const = 0;
  167 + virtual void _project(const TemplateList & src, TemplateList & dst) const = 0;
  168 +
  169 + CompositeTransform() : TimeVaryingTransform(false) {}
  170 +};
  171 +
  172 +}
  173 +
  174 +#endif
openbr/plugins/output.cpp
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 #include <iostream> 35 #include <iostream>
36 #include <limits> 36 #include <limits>
37 #include <assert.h> 37 #include <assert.h>
38 -#include <openbr/openbr_plugin.h> 38 +#include "openbr_internal.h"
39 39
40 #include "openbr/core/bee.h" 40 #include "openbr/core/bee.h"
41 #include "openbr/core/common.h" 41 #include "openbr/core/common.h"
openbr/plugins/pbd.cpp
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 #include <opencv2/highgui/highgui.hpp> 3 #include <opencv2/highgui/highgui.hpp>
4 4
5 -#include <openbr/openbr_plugin.h> 5 +#include "openbr_internal.h"
6 6
7 #include "core/opencvutils.h" 7 #include "core/opencvutils.h"
8 8
openbr/plugins/pixel.cpp
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 * limitations under the License. * 14 * limitations under the License. *
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 -#include <openbr/openbr_plugin.h> 17 +#include "openbr_internal.h"
18 18
19 using namespace cv; 19 using namespace cv;
20 20
openbr/plugins/plugins.cmake
1 # Add source to BR_THIRDPARTY_SRC 1 # Add source to BR_THIRDPARTY_SRC
2 # Add libs to BR_THIRDPARTY_LIBS 2 # Add libs to BR_THIRDPARTY_LIBS
3 3
4 -file(GLOB PLUGINS plugins/*.cpp) 4 +file(GLOB PLUGINS plugins/*.cpp plugins/*.h)
5 foreach(PLUGIN ${PLUGINS} ${BR_THIRDPARTY_PLUGINS}) 5 foreach(PLUGIN ${PLUGINS} ${BR_THIRDPARTY_PLUGINS})
6 get_filename_component(PLUGIN_BASENAME ${PLUGIN} NAME_WE) 6 get_filename_component(PLUGIN_BASENAME ${PLUGIN} NAME_WE)
7 get_filename_component(PLUGIN_PATH ${PLUGIN} PATH) 7 get_filename_component(PLUGIN_PATH ${PLUGIN} PATH)
openbr/plugins/pp5.cpp
@@ -11,8 +11,7 @@ @@ -11,8 +11,7 @@
11 #include <pittpatt_raw_image_io.h> 11 #include <pittpatt_raw_image_io.h>
12 #include <pittpatt_sdk.h> 12 #include <pittpatt_sdk.h>
13 #include <pittpatt_license.h> 13 #include <pittpatt_license.h>
14 -#include <openbr/openbr_plugin.h>  
15 - 14 +#include "openbr_internal.h"
16 #include "openbr/core/resource.h" 15 #include "openbr/core/resource.h"
17 16
18 #define TRY(CC) \ 17 #define TRY(CC) \
openbr/plugins/qtnetwork.cpp
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 #include <QTcpSocket> 5 #include <QTcpSocket>
6 #include <opencv2/highgui/highgui.hpp> 6 #include <opencv2/highgui/highgui.hpp>
7 #include <http_parser.h> 7 #include <http_parser.h>
8 -#include <openbr/openbr_plugin.h> 8 +#include "openbr_internal.h"
9 9
10 using namespace cv; 10 using namespace cv;
11 11
openbr/plugins/quality.cpp
1 #include <QFutureSynchronizer> 1 #include <QFutureSynchronizer>
2 #include <QtConcurrent> 2 #include <QtConcurrent>
3 -#include <openbr/openbr_plugin.h> 3 +#include "openbr_internal.h"
4 4
5 #include "openbr/core/common.h" 5 #include "openbr/core/common.h"
6 #include "openbr/core/opencvutils.h" 6 #include "openbr/core/opencvutils.h"
openbr/plugins/quantize.cpp
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 16
17 #include <QFutureSynchronizer> 17 #include <QFutureSynchronizer>
18 #include <QtConcurrentRun> 18 #include <QtConcurrentRun>
19 -#include <openbr/openbr_plugin.h> 19 +#include "openbr_internal.h"
20 20
21 #include "openbr/core/common.h" 21 #include "openbr/core/common.h"
22 #include "openbr/core/opencvutils.h" 22 #include "openbr/core/opencvutils.h"
openbr/plugins/quantize2.cpp
1 #include <QFutureSynchronizer> 1 #include <QFutureSynchronizer>
2 #include <QtConcurrent> 2 #include <QtConcurrent>
3 -#include <openbr/openbr_plugin.h> 3 +#include "openbr_internal.h"
4 4
5 #include "openbr/core/common.h" 5 #include "openbr/core/common.h"
6 #include "openbr/core/opencvutils.h" 6 #include "openbr/core/opencvutils.h"
openbr/plugins/random.cpp
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 -#include <openbr/openbr_plugin.h> 18 +#include "openbr_internal.h"
19 19
20 #include "openbr/core/common.h" 20 #include "openbr/core/common.h"
21 #include "openbr/core/opencvutils.h" 21 #include "openbr/core/opencvutils.h"
openbr/plugins/reduce.cpp
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 * limitations under the License. * 14 * limitations under the License. *
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 -#include <openbr/openbr_plugin.h> 17 +#include "openbr_internal.h"
18 18
19 using namespace cv; 19 using namespace cv;
20 20
openbr/plugins/regions.cpp
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 -#include <openbr/openbr_plugin.h> 18 +#include "openbr_internal.h"
19 19
20 using namespace cv; 20 using namespace cv;
21 21
openbr/plugins/register.cpp
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 -#include <openbr/openbr_plugin.h> 18 +#include "openbr_internal.h"
19 19
20 #include "openbr/core/opencvutils.h" 20 #include "openbr/core/opencvutils.h"
21 21
openbr/plugins/sentence.cpp
1 #include <stdint.h> 1 #include <stdint.h>
2 -#include <openbr/openbr_plugin.h> 2 +#include "openbr_internal.h"
3 3
4 using namespace cv; 4 using namespace cv;
5 5
openbr/plugins/stasm.cpp
1 #include <stasm_dll.hpp> 1 #include <stasm_dll.hpp>
2 #include <opencv2/highgui/highgui.hpp> 2 #include <opencv2/highgui/highgui.hpp>
3 -#include <openbr/openbr_plugin.h> 3 +#include "openbr_internal.h"
4 4
5 using namespace cv; 5 using namespace cv;
6 6
openbr/plugins/stream.cpp
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 #include <QMap> 5 #include <QMap>
6 #include <opencv/highgui.h> 6 #include <opencv/highgui.h>
7 #include <QtConcurrent> 7 #include <QtConcurrent>
8 -#include <openbr/openbr_plugin.h> 8 +#include "openbr_internal.h"
9 9
10 #include "openbr/core/common.h" 10 #include "openbr/core/common.h"
11 #include "openbr/core/opencvutils.h" 11 #include "openbr/core/opencvutils.h"
openbr/plugins/svm.cpp
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 #include <QTemporaryFile> 17 #include <QTemporaryFile>
18 #include <opencv2/core/core.hpp> 18 #include <opencv2/core/core.hpp>
19 #include <opencv2/ml/ml.hpp> 19 #include <opencv2/ml/ml.hpp>
20 -#include <openbr/openbr_plugin.h> 20 +#include "openbr_internal.h"
21 21
22 #include "openbr/core/opencvutils.h" 22 #include "openbr/core/opencvutils.h"
23 23
openbr/plugins/synthetic.cpp
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 -#include <openbr/openbr_plugin.h> 18 +#include "openbr_internal.h"
19 19
20 #include "openbr/core/opencvutils.h" 20 #include "openbr/core/opencvutils.h"
21 21
openbr/plugins/validate.cpp
1 #include <QFutureSynchronizer> 1 #include <QFutureSynchronizer>
2 #include <QtConcurrentRun> 2 #include <QtConcurrentRun>
3 -#include <openbr/openbr_plugin.h> 3 +#include "openbr_internal.h"
4 #include <openbr/core/qtutils.h> 4 #include <openbr/core/qtutils.h>
5 5
6 namespace br 6 namespace br
openbr/plugins/wavelet.cpp
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
18 -#include <openbr/openbr_plugin.h> 18 +#include "openbr_internal.h"
19 19
20 using namespace cv; 20 using namespace cv;
21 21
openbr/plugins/youtube.cpp
1 #include <QCoreApplication> 1 #include <QCoreApplication>
2 #include <QProcess> 2 #include <QProcess>
3 -#include <openbr/openbr_plugin.h> 3 +#include "openbr_internal.h"
4 4
5 #include "openbr/core/common.h" 5 #include "openbr/core/common.h"
6 6