diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index 2133c1f..620dfe2 100644 --- a/openbr/core/core.cpp +++ b/openbr/core/core.cpp @@ -305,7 +305,7 @@ struct AlgorithmCore tail.removeFirst(); QStringList toRemove; - foreach(const QString &s, tail) + foreach (const QString &s, tail) toRemove.append(s.split(',').at(1)); QSet duplicates = QSet::fromList(toRemove); @@ -313,7 +313,7 @@ struct AlgorithmCore QStringList fileNames = inputFiles.names(); QList indices; - foreach(const QString &d, duplicates) + foreach (const QString &d, duplicates) indices.append(fileNames.indexOf(d)); std::sort(indices.begin(),indices.end(),std::greater()); @@ -426,10 +426,8 @@ struct AlgorithmCore // which compares incoming templates against a gallery, we will handle enrollment of the row set by simply // building a transform that does enrollment (using the current algorithm), then does the comparison in one // step. This way, we don't have to retain the complete enrolled row gallery in memory, or on disk. - else if(!(QStringList() << "gal" << "mem" << "template").contains(rowGallery.suffix())) - { + else if (!(QStringList() << "gal" << "mem" << "template").contains(rowGallery.suffix())) needEnrollRows = true; - } // At this point, we have decided how we will structure the comparison (either in transpose mode, or not), // and have the column gallery enrolled, and have decided whether or not we need to enroll the row gallery. diff --git a/openbr/core/eval.cpp b/openbr/core/eval.cpp index 8679a10..27ac297 100644 --- a/openbr/core/eval.cpp +++ b/openbr/core/eval.cpp @@ -332,16 +332,14 @@ float InplaceEval(const QString &simmat, const QString &target, const QString &q qint64 idx = 0; bool done = false; - do - { + do { TemplateList temp = columnGal->readBlock(&done); QStringList tempLabels = File::get(temp, "Label"); - foreach(QString st, tempLabels) - { - if (!galleryIndices.contains(st)) { + foreach (QString st, tempLabels) { + if (!galleryIndices.contains(st)) galleryIndices.insert(st, QList()); - } + galleryIndices[st].append(idx); idx++; } @@ -357,21 +355,17 @@ float InplaceEval(const QString &simmat, const QString &target, const QString &q probeGallery->set_readBlockSize(10000); done = false; qint64 row_count = 0; - do - { + do { TemplateList temp = probeGallery->readBlock(&done); QStringList probeLabels = File::get(temp, "Label"); - for (int i=0; i < probeLabels.size();i++) - { + for (int i=0; i < probeLabels.size();i++) { row_count++; - if (!galleryIndices.contains(probeLabels[i])) { + if (!galleryIndices.contains(probeLabels[i])) continue; - } QList colMask = galleryIndices[probeLabels[i]]; - foreach(qint64 colID, colMask) - { + foreach (qint64 colID, colMask) { float score; file.seek(data_pos + i * rowSize + colID * typeSize); file.read((char *) &score, sizeof(float)); @@ -383,7 +377,7 @@ float InplaceEval(const QString &simmat, const QString &target, const QString &q } } - } while(!done); + } while (!done); QMap noImpostors = genScoresToCounts; @@ -403,16 +397,14 @@ float InplaceEval(const QString &simmat, const QString &target, const QString &q Mat blockMat(bSize, cols, CV_32FC1); qint64 bCount = 0; - do - { + do { bCount++; TemplateList temp = probeGallery2->readBlock(&done); QStringList probeLabels = File::get(temp, "Label"); temp.clear(); file.read((char *) blockMat.data, rowSize * probeLabels.length()); - for (int i=0; i < probeLabels.size();i++) - { + for (int i=0; i < probeLabels.size();i++) { row_count++; aRow = blockMat.row(i); @@ -445,8 +437,7 @@ float InplaceEval(const QString &simmat, const QString &target, const QString &q i->impCount++; } } - - } while(!done); + } while (!done); QList operatingPoints; qint64 genAccum = 0; diff --git a/openbr/core/qtutils.cpp b/openbr/core/qtutils.cpp index cd1f915..085a7a5 100644 --- a/openbr/core/qtutils.cpp +++ b/openbr/core/qtutils.cpp @@ -105,9 +105,9 @@ void writeFile(const QString &file, const QStringList &lines) if (!f.open(QFile::WriteOnly)) qFatal("Failed to open %s for writing.", qPrintable(file)); - foreach(const QString & line, lines) { + foreach (const QString & line, lines) f.write((line+"\n").toLocal8Bit() ); - } + f.close(); } @@ -429,7 +429,7 @@ QString toString(const QVariantList &variantList) { QStringList variants; - foreach(const QVariant &variant, variantList) + foreach (const QVariant &variant, variantList) variants.append(toString(variant)); if (!variants.isEmpty()) return "[" + variants.join(", ") + "]"; diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index e127f55..a720431 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -205,7 +205,7 @@ QList File::namedRects() const const QVariant &variant = m_metadata[key]; if (variant.canConvert()) rects.append(variant.value()); - else if(variant.canConvert >()) { + else if (variant.canConvert >()) { QList list = variant.value >(); for (int i=0;i < list.size();i++) { @@ -1323,8 +1323,7 @@ QList Transform::getChildren() const TemplateEvent *Transform::getEvent(const QString &name) { - foreach(Transform *child, getChildren()) - { + foreach (Transform *child, getChildren()) { TemplateEvent *probe = child->getEvent(name); if (probe) return probe; @@ -1347,9 +1346,9 @@ void Transform::train(const TemplateList &data) void Transform::train(const QList &data) { TemplateList combined; - foreach(const TemplateList &set, data) { + foreach (const TemplateList &set, data) combined.append(set); - } + train(combined); } diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index 0f9d8a0..bc30f40 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -494,7 +494,7 @@ struct TemplateList : public QList