Commit d08187c73da493f6eff82ced6a0f0cb417699791

Authored by Scott Klum
1 parent af97fc18

Arg

openbr/janus.cpp
1   -#include "janus.h"
2   -#include "janus_io.h"
  1 +#include "iarpa_janus.h"
  2 +#include "iarpa_janus_io.h"
3 3 #include "openbr_plugin.h"
4 4  
5 5 using namespace br;
... ... @@ -12,6 +12,21 @@ size_t janus_max_template_size()
12 12 return 33554432; // 32 MB
13 13 }
14 14  
  15 +janus_error janus_flatten_gallery(const janus_gallery gallery, janus_flat_gallery flat_gallery, size_t *bytes)
  16 +{
  17 +
  18 +}
  19 +
  20 +janus_error janus_compare(const janus_flat_gallery target, const size_t target_bytes, const janus_flat_gallery query, const size_t query_bytes, float *similarity_matrix, janus_template_id *target_ids, janus_template_id *query_ids)
  21 +{
  22 +
  23 +}
  24 +
  25 +janus_error janus_flatten_template(const janus_template template_, janus_flat_template flat_template, size_t *bytes)
  26 +{
  27 +
  28 +}
  29 +
15 30 janus_error janus_initialize(const char *sdk_path, const char *model_file)
16 31 {
17 32 int argc = 1;
... ...
openbr/plugins/landmarks.cpp
... ... @@ -465,7 +465,7 @@ class NormalizePointsTransform : public UntrainableTransform
465 465  
466 466 Q_PROPERTY(int index READ get_index WRITE set_index RESET reset_index STORED false)
467 467 BR_PROPERTY(int, index, 0)
468   -;
  468 +
469 469 void project(const Template &src, Template &dst) const
470 470 {
471 471 dst = src;
... ... @@ -474,7 +474,9 @@ class NormalizePointsTransform : public UntrainableTransform
474 474 QPointF normPoint = points.at(index);
475 475  
476 476 QList<QPointF> normalizedPoints;
477   - normalizedPoints.append(normPoint);
  477 + // We have nose and two eyes and I want a feature vector like:
  478 + // (nose.x-right_eye.x,nose.y-right_eye.y),(nose.x-left_eye.x,nose.y-left_eye.y),(0,0) because we're centering on the nose
  479 +
478 480 for (int i=0; i<points.size(); i++)
479 481 if (i!=index)
480 482 normalizedPoints.append(normPoint-points[i]);
... ... @@ -485,6 +487,32 @@ class NormalizePointsTransform : public UntrainableTransform
485 487  
486 488 BR_REGISTER(Transform, NormalizePointsTransform)
487 489  
  490 +class PointDisplacementTransform : public UntrainableTransform
  491 +{
  492 + Q_OBJECT
  493 +
  494 + void project(const Template &src, Template &dst) const
  495 + {
  496 + dst = src;
  497 +
  498 + QList<QPointF> points = dst.file.points();
  499 + QList<QPointF> normalizedPoints;
  500 +
  501 + for (int i=0; i<points.size(); i++)
  502 + for (int j=0; j<points.size(); j++)
  503 + if (j!=i) {
  504 + QPointF normalizedPoint = points[i]-points[j];
  505 + normalizedPoint.setX(pow(normalizedPoint.x(),2));
  506 + normalizedPoint.setY(pow(normalizedPoint.y(),2));
  507 + normalizedPoints.append(normalizedPoint);
  508 + }
  509 +
  510 + dst.file.setPoints(normalizedPoints);
  511 + }
  512 +};
  513 +
  514 +BR_REGISTER(Transform, PointDisplacementTransform)
  515 +
488 516 } // namespace br
489 517  
490 518 #include "landmarks.moc"
... ...
openbr/plugins/misc.cpp
... ... @@ -38,8 +38,6 @@ class OpenTransform : public UntrainableMetaTransform
38 38  
39 39 void project(const Template &src, Template &dst) const
40 40 {
41   - qDebug() << "here";
42   -
43 41 dst.file = src.file;
44 42 if (src.empty()) {
45 43 if (Globals->verbose)
... ... @@ -485,7 +483,6 @@ class SaveMatTransform : public UntrainableMetaTransform
485 483  
486 484 void project(const Template &src, Template &dst) const
487 485 {
488   - qDebug() << "saving mat";
489 486 dst = src;
490 487 dst.file.set(propName, QVariant::fromValue(dst.m()));
491 488 }
... ...
openbr/plugins/nn.cpp
... ... @@ -67,10 +67,10 @@ class MLPTransform : public MetaTransform
67 67 void init()
68 68 {
69 69 Mat layers = Mat(neuronsPerLayer.size(), 1, CV_32SC1);
70   - for (int i=0; i<neuronsPerLayer.size(); i++) {
  70 + for (int i=0; i<neuronsPerLayer.size(); i++)
71 71 layers.row(i) = Scalar(neuronsPerLayer.at(i));
72   - }
73   - mlp.create(layers,CvANN_MLP::SIGMOID_SYM, 1, 1);
  72 +
  73 + mlp.create(layers,CvANN_MLP::SIGMOID_SYM, 1, 1);
74 74 }
75 75  
76 76 void train(const TemplateList &data)
... ...
openbr/plugins/stream.cpp
... ... @@ -1531,6 +1531,11 @@ public:
1531 1531 processingStages.clear();
1532 1532 }
1533 1533  
  1534 + DirectStreamTransform()
  1535 + {
  1536 + readStage = NULL;
  1537 + }
  1538 +
1534 1539 protected:
1535 1540 QList<bool> stage_variance;
1536 1541  
... ... @@ -1594,6 +1599,14 @@ public:
1594 1599  
1595 1600 bool timeVarying() const { return true; }
1596 1601  
  1602 + // Stream acts as a shallow interface to DirectStream, so it's fine to remove ourselves here
  1603 + Transform *simplify(bool &newTransform)
  1604 + {
  1605 + newTransform = false;
  1606 +
  1607 + return basis->simplify(newTransform);
  1608 + }
  1609 +
1597 1610 void project(const Template &src, Template &dst) const
1598 1611 {
1599 1612 basis->project(src,dst);
... ...
openbr/plugins/svm.cpp
... ... @@ -74,7 +74,7 @@ static void trainSVM(SVM &amp;svm, Mat data, Mat lab, int kernel, int type, float C,
74 74 svm.train_auto(data, lab, Mat(), Mat(), params, 5);
75 75 } catch (...) {
76 76 qWarning("Some classes do not contain sufficient examples or are not discriminative enough for accurate SVM classification.");
77   - svm.train(data, lab);
  77 + svm.train(data, lab, Mat(), Mat(), params);
78 78 }
79 79 } else {
80 80 params.C = C;
... ... @@ -161,7 +161,8 @@ private:
161 161 dst.m().at<float>(0, 0) = prediction;
162 162 // positive values ==> first class
163 163 // negative values ==> second class
164   - prediction = prediction > 0 ? 0 : 1;
  164 + if (type != EPS_SVR && type != NU_SVR)
  165 + prediction = prediction > 0 ? 0 : 1;
165 166 }
166 167 if (type == EPS_SVR || type == NU_SVR) {
167 168 dst.file.set(outputVariable, prediction);
... ...