From f04a4fa4354b7eb5a886a5cad84c80cb6fb3435e Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Thu, 3 Jul 2014 16:41:36 -0400 Subject: [PATCH] In AlgorithmCore::compare, use setPropertyRecursive to set the gallery --- openbr/core/core.cpp | 37 +++++++++++++------------------------ openbr/plugins/pp5.cpp | 2 -- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index 1a4c431..c4b2c2f 100644 --- a/openbr/core/core.cpp +++ b/openbr/core/core.cpp @@ -271,8 +271,7 @@ struct AlgorithmCore realOutput->set_blockRows(INT_MAX); realOutput->set_blockCols(INT_MAX); realOutput->setBlock(0,0); - for (int i=0; i < queries.length(); i++) - { + for (int i=0; i < queries.length(); i++) { float res = distance->compare(queries[i], targets[i]); realOutput->setRelative(res, 0,i); } @@ -374,16 +373,14 @@ struct AlgorithmCore qint64 rowSize; Gallery *temp; - if (transposeMode) - { + if (transposeMode) { rowGallery = targetGallery; colGallery = queryGallery; temp = Gallery::make(targetGallery); } else - { temp = Gallery::make(queryGallery); - } + rowSize = temp->totalSize(); delete temp; @@ -395,20 +392,17 @@ struct AlgorithmCore QString targetExtension = multiProcess ? "gal" : "mem"; // If the column gallery is not already of the appropriate type, we need to do something - if (colGallery.suffix() != targetExtension) - { + if (colGallery.suffix() != targetExtension) { // Build the name of a gallery containing the enrolled data, of the appropriate type. colEnrolledGallery = colGallery.baseName() + colGallery.hash() + (multiProcess ? ".gal" : ".mem"); // Check if we have to do real enrollment, and not just convert the gallery's type. if (!(QStringList() << "gal" << "template" << "mem").contains(colGallery.suffix())) - { enroll(colGallery, colEnrolledGallery); - } + // If the gallery does have enrolled templates, but is not the right type, we do a simple // type conversion for it. - else - { + else { QScopedPointer readColGallery(Gallery::make(colGallery)); TemplateList templates = readColGallery->read(); QScopedPointer enrolledColOutput(Gallery::make(colEnrolledGallery)); @@ -417,8 +411,7 @@ struct AlgorithmCore } // We have handled the column gallery, now decide whehter or not we have to enroll the row gallery. - if (selfCompare) - { + if (selfCompare) { // For self-comparisons, we just use the already enrolled column set. rowGallery = colEnrolledGallery; } @@ -444,17 +437,15 @@ struct AlgorithmCore // vector. QString compareRegionDesc; if (this->galleryCompareString.isEmpty() ) - compareRegionDesc = "Pipe([GalleryCompare("+Globals->algorithm + "," + colEnrolledGallery.flat() + ")])"; + compareRegionDesc = "Pipe([GalleryCompare("+Globals->algorithm+")])"; else - compareRegionDesc = "Pipe(["+this->galleryCompareString+"("+Globals->algorithm + "," + colEnrolledGallery.flat() + ")])"; + compareRegionDesc = "Pipe(["+galleryCompareString+"])"; QScopedPointer compareRegion; // If we need to enroll the row set, we add the current algorithm's enrollment transform before the // GalleryCompare in a pipe. - if (needEnrollRows) - { - if (!multiProcess) - { + if (needEnrollRows) { + if (!multiProcess) { compareRegionDesc = compareRegionDesc; compareRegion.reset(Transform::make(compareRegionDesc,NULL)); CompositeTransform *downcast = dynamic_cast (compareRegion.data()); @@ -464,8 +455,7 @@ struct AlgorithmCore downcast->transforms.prepend(this->transform.data()); downcast->init(); } - else - { + else { compareRegionDesc = "ProcessWrapper(" + this->transformString + "+" + compareRegionDesc + ")"; compareRegion.reset(Transform::make(compareRegionDesc, NULL)); } @@ -479,8 +469,7 @@ struct AlgorithmCore // At this point, compareRegion is a transform, which optionally does enrollment, then compares the row // set against the column set. If in multi-process mode, the enrollment and comparison are wrapped in a // ProcessWrapper transform, and will be transparently run in multiple processes. - compareRegion->init(); - + compareRegion->setPropertyRecursive("galleryName", colEnrolledGallery.flat()); // We also need to add Output and progress counting to the algorithm we are building, so we will assign them to // two stages of a pipe. diff --git a/openbr/plugins/pp5.cpp b/openbr/plugins/pp5.cpp index 53ea18a..e605839 100644 --- a/openbr/plugins/pp5.cpp +++ b/openbr/plugins/pp5.cpp @@ -445,9 +445,7 @@ class PP5GalleryTransform: public UntrainableMetaTransform , public PP5Context { Q_OBJECT - Q_PROPERTY(QString junk READ get_junk WRITE set_junk RESET reset_junk STORED false) Q_PROPERTY(QString galleryName READ get_galleryName WRITE set_galleryName RESET reset_galleryName STORED false) - BR_PROPERTY(QString, junk, "") BR_PROPERTY(QString, galleryName, "") ppr_gallery_type target; -- libgit2 0.21.4