diff --git a/openbr/core/bee.cpp b/openbr/core/bee.cpp index 5b93370..a513b74 100644 --- a/openbr/core/bee.cpp +++ b/openbr/core/bee.cpp @@ -265,9 +265,6 @@ cv::Mat BEE::makeMask(const br::FileList &targets, const br::FileList &queries, QList targetPartitions = targets.crossValidationPartitions(); QList queryPartitions = queries.crossValidationPartitions(); - for (int i = 0; i < 5; i++) qDebug() << "QueryPartition " << queries[i].fileName() << ": " << queryPartitions[i]; - for (int i = 0; i < 5; i++) qDebug() << "TargetPartition " << targets[i].fileName() << ": " << targetPartitions[i]; - Mat mask(queries.size(), targets.size(), CV_8UC1); for (int i=0; i(i,j) = val; diff --git a/openbr/core/plot.cpp b/openbr/core/plot.cpp index 25406a1..d1f4d27 100644 --- a/openbr/core/plot.cpp +++ b/openbr/core/plot.cpp @@ -269,7 +269,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) } // Write Cumulative Match Characteristic (CMC) curve - const int Max_Retrieval = 200; + const int Max_Retrieval = 100; const int Report_Retrieval = 5; float reportRetrievalRate = -1; @@ -507,11 +507,11 @@ bool Plot(const QStringList &files, const br::File &destination, bool show) QString(" + theme(aspect.ratio=1)\n\n"))); p.file.write(qPrintable(QString("ggplot(CMC, aes(x=X, y=Y%1%2)) + xlab(\"Rank\") + ylab(\"Retrieval Rate\")").arg(p.major.size > 1 ? QString(" ,colour=factor(%1)").arg(p.major.header) : QString(), p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + - ((p.major.smooth || p.minor.smooth) ? (minimalist ? " + stat_summary(geom=\"line\", fun.y=mean)" : " + stat_summary(geom=\"line\", fun.y=min, aes(linetype=\"Min/Max\")) + stat_summary(geom=\"line\", fun.y=max, aes(linetype=\"Min/Max\")) + stat_summary(geom=\"line\", fun.y=mean, aes(linetype=\"Mean\")) + scale_linetype_manual(\"Legend\", values=c(\"Mean\"=1, \"Min/Max\"=2))") : " + geom_line()") + + ((p.major.smooth || p.minor.smooth) ? (minimalist ? " + stat_summary(geom=\"line\", lwd=3, fun.y=mean)" : " + stat_summary(geom=\"line\", fun.y=min, aes(linetype=\"Min/Max\")) + stat_summary(geom=\"line\", fun.y=max, aes(linetype=\"Min/Max\")) + stat_summary(geom=\"line\", fun.y=mean, aes(linetype=\"Mean\")) + scale_linetype_manual(\"Legend\", values=c(\"Mean\"=1, \"Min/Max\"=2))") : " + geom_line()") + (minimalist ? "" : " + scale_x_log10(labels=c(1,5,10,50,100), breaks=c(1,5,10,50,100)) + annotation_logticks(sides=\"b\")") + (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + - QString(" + theme_minimal() + scale_y_continuous(labels=percent)\n\n"))); + QString(" + theme_blank() + scale_y_continuous(labels=percent)\n\n"))); p.file.write(qPrintable(QString("qplot(factor(%1)%2, data=BC, %3").arg(p.major.smooth ? (p.minor.header.isEmpty() ? "Algorithm" : p.minor.header) : p.major.header, (p.major.smooth || p.minor.smooth) ? ", Y" : "", (p.major.smooth || p.minor.smooth) ? "geom=\"boxplot\"" : "geom=\"bar\", position=\"dodge\", weight=Y") + (p.major.size > 1 ? QString(", fill=factor(%1)").arg(p.major.header) : QString()) + diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 8e5a725..7579e75 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -401,7 +401,6 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) { TemplateList templates; foreach (const br::File &file, gallery.split()) { - qDebug() << file.name; QScopedPointer i(Gallery::make(file)); TemplateList newTemplates = i->read(); @@ -432,7 +431,11 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) newTemplates[i].file.set("Gallery", gallery.name); if (crossValidate > 0) { - if (newTemplates[i].file.getBool("allPartitions")) { + if (newTemplates[i].file.getBool("duplicatePartitions")) { + // The duplicatePartitions flag is used to add target images + // crossValidate times to the simmat/mask + // when multiple training sets are being used + // Set template to the first parition newTemplates[i].file.set("Partition", QVariant(0)); @@ -442,6 +445,11 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) allPartitionTemplate.file.set("Partition", j); newTemplates.insert(i+1, allPartitionTemplate); } + } else if (newTemplates[i].file.getBool("allPartitions")) { + // The allPartitions flag is used to add an extended set + // of target images to every partition + + newTemplates[i].file.set("Partition", -1); } else { const QByteArray md5 = QCryptographicHash::hash(newTemplates[i].file.subject().toLatin1(), QCryptographicHash::Md5); // Select the right 8 hex characters so that it can be represented as a 64 bit integer without overflow diff --git a/openbr/plugins/algorithms.cpp b/openbr/plugins/algorithms.cpp index 2e7763d..2b3f270 100644 --- a/openbr/plugins/algorithms.cpp +++ b/openbr/plugins/algorithms.cpp @@ -52,6 +52,7 @@ class AlgorithmsInitializer : public Initializer Globals->abbreviations.insert("SmallSURF", "Open+LimitSize(512)+KeyPointDetector(SURF)+KeyPointDescriptor(SURF):KeyPointMatcher(BruteForce)"); Globals->abbreviations.insert("ColorHist", "Open+LimitSize(512)!EnsureChannels(3)+SplitChannels+Hist(256,0,8)+Cat+Normalize(L1):L2"); Globals->abbreviations.insert("ImageClassification", "Open+CropSquare+LimitSize(256)+Cvt(Gray)+Gradient+Bin(0,360,9,true)+Merge+Integral+RecursiveIntegralSampler(4,2,8,Singleton(KMeans(256)))+Cat+CvtFloat+Hist(256)+KNN(5,Dist(L1),false,5)+Rename(KNN,Subject)"); + Globals->abbreviations.insert("TanTriggs", "Blur(1.1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)"); // Hash Globals->abbreviations.insert("FileName", "Name+Identity:Identical"); diff --git a/openbr/plugins/distance.cpp b/openbr/plugins/distance.cpp index 52a1733..c606584 100644 --- a/openbr/plugins/distance.cpp +++ b/openbr/plugins/distance.cpp @@ -198,7 +198,6 @@ class AverageDistance : public Distance float score = 0; for (int i = 0; i < a.size(); i++) { - qDebug() << "Computing score for: " << a.file.name << " vs. " << b.file.name; score += distance->compare(a[i],b[i]); } @@ -295,10 +294,52 @@ class IdenticalDistance : public Distance if (am.data[i] != bm.data[i]) return 0; return 1; } -}; +}; BR_REGISTER(Distance, IdenticalDistance) +class HeatMapDistance : public Distance +{ + Q_OBJECT + Q_PROPERTY(br::Distance* distance READ get_distance WRITE set_distance RESET reset_distance STORED false) + BR_PROPERTY(br::Distance*, distance, make("Dist(L2)")) + Q_PROPERTY(int rowSize READ get_rowSize WRITE set_rowSize RESET reset_rowSize STORED false) + BR_PROPERTY(int, rowSize, 1) + + void train(const TemplateList &src) + { + distance->train(src); + } + + + float compare(const Template &a, const Template &b) const + { + qFatal("HeatMap expects a TemplateList"); + + (void) a; (void) b; + } + + void compare(const TemplateList &target, const TemplateList &query, Output *output) const + { + int i = 0; + int j = 0; + for (int index = 0; index < target.size(); index++) { + float score = distance->compare(target[index],query[index]); + + if (j >= rowSize) { + i++; + j = 0; + } + + output->setRelative(score, i, j); + + j++; + } + } +}; + +BR_REGISTER(Distance, HeatMapDistance) + } // namespace br #include "distance.moc" diff --git a/openbr/plugins/regions.cpp b/openbr/plugins/regions.cpp index efc9f09..b6bba45 100644 --- a/openbr/plugins/regions.cpp +++ b/openbr/plugins/regions.cpp @@ -228,7 +228,6 @@ class RectFromPointsTransform : public UntrainableTransform } } - // Padding is .05 double width = maxX-minX; double deltaWidth = width*padding; width += deltaWidth; diff --git a/openbr/plugins/stasm.cpp b/openbr/plugins/stasm.cpp index d7bee87..1e3ca2a 100644 --- a/openbr/plugins/stasm.cpp +++ b/openbr/plugins/stasm.cpp @@ -21,7 +21,7 @@ class StasmInitializer : public Initializer Globals->abbreviations.insert("RectFromStasmEyes","RectFromPoints([27, 28, 29, 30, 31, 32, 33, 34, 35, 36],0.125,6.0)+Resize(44,164)"); // Globals->abbreviations.insert("RectFromStasmJaw","RectFromPoints([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],10)"); Globals->abbreviations.insert("RectFromStasmBrow","RectFromPoints([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],0.25,6.5)+Resize(44,230)"); - Globals->abbreviations.insert("RectFromStasmNose","RectFromPoints([38, 39, 40, 41, 42, 43, 44, 67],0.1,1.5)+Resize(44,44)"); + Globals->abbreviations.insert("RectFromStasmNose","RectFromPoints([38, 39, 40, 41, 42, 43, 44, 67],0.15,1.25)+Resize(44,44)"); Globals->abbreviations.insert("RectFromStasmMouth","RectFromPoints([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66],0.3,3.0)+Resize(26,68)"); } }; @@ -60,7 +60,6 @@ class StasmTransform : public UntrainableTransform } for (int i = 0; i < numLandmarks; i++) { - qDebug() << QPointF(landmarks[2 * i], landmarks[2 * i + 1]); dst.file.appendPoint(QPointF(landmarks[2 * i], landmarks[2 * i + 1])); }