Commit f04a4fa4354b7eb5a886a5cad84c80cb6fb3435e

Authored by Charles Otto
1 parent cdb6b4fb

In AlgorithmCore::compare, use setPropertyRecursive to set the gallery

This avoids the need for the arguments of GalleryCompare and other
gallery comparison style transforms to be precisely aligned.

Update some brace placements.
openbr/core/core.cpp
@@ -271,8 +271,7 @@ struct AlgorithmCore @@ -271,8 +271,7 @@ struct AlgorithmCore
271 realOutput->set_blockRows(INT_MAX); 271 realOutput->set_blockRows(INT_MAX);
272 realOutput->set_blockCols(INT_MAX); 272 realOutput->set_blockCols(INT_MAX);
273 realOutput->setBlock(0,0); 273 realOutput->setBlock(0,0);
274 - for (int i=0; i < queries.length(); i++)  
275 - { 274 + for (int i=0; i < queries.length(); i++) {
276 float res = distance->compare(queries[i], targets[i]); 275 float res = distance->compare(queries[i], targets[i]);
277 realOutput->setRelative(res, 0,i); 276 realOutput->setRelative(res, 0,i);
278 } 277 }
@@ -374,16 +373,14 @@ struct AlgorithmCore @@ -374,16 +373,14 @@ struct AlgorithmCore
374 qint64 rowSize; 373 qint64 rowSize;
375 374
376 Gallery *temp; 375 Gallery *temp;
377 - if (transposeMode)  
378 - { 376 + if (transposeMode) {
379 rowGallery = targetGallery; 377 rowGallery = targetGallery;
380 colGallery = queryGallery; 378 colGallery = queryGallery;
381 temp = Gallery::make(targetGallery); 379 temp = Gallery::make(targetGallery);
382 } 380 }
383 else 381 else
384 - {  
385 temp = Gallery::make(queryGallery); 382 temp = Gallery::make(queryGallery);
386 - } 383 +
387 rowSize = temp->totalSize(); 384 rowSize = temp->totalSize();
388 delete temp; 385 delete temp;
389 386
@@ -395,20 +392,17 @@ struct AlgorithmCore @@ -395,20 +392,17 @@ struct AlgorithmCore
395 QString targetExtension = multiProcess ? "gal" : "mem"; 392 QString targetExtension = multiProcess ? "gal" : "mem";
396 393
397 // If the column gallery is not already of the appropriate type, we need to do something 394 // If the column gallery is not already of the appropriate type, we need to do something
398 - if (colGallery.suffix() != targetExtension)  
399 - { 395 + if (colGallery.suffix() != targetExtension) {
400 // Build the name of a gallery containing the enrolled data, of the appropriate type. 396 // Build the name of a gallery containing the enrolled data, of the appropriate type.
401 colEnrolledGallery = colGallery.baseName() + colGallery.hash() + (multiProcess ? ".gal" : ".mem"); 397 colEnrolledGallery = colGallery.baseName() + colGallery.hash() + (multiProcess ? ".gal" : ".mem");
402 398
403 // Check if we have to do real enrollment, and not just convert the gallery's type. 399 // Check if we have to do real enrollment, and not just convert the gallery's type.
404 if (!(QStringList() << "gal" << "template" << "mem").contains(colGallery.suffix())) 400 if (!(QStringList() << "gal" << "template" << "mem").contains(colGallery.suffix()))
405 - {  
406 enroll(colGallery, colEnrolledGallery); 401 enroll(colGallery, colEnrolledGallery);
407 - } 402 +
408 // If the gallery does have enrolled templates, but is not the right type, we do a simple 403 // If the gallery does have enrolled templates, but is not the right type, we do a simple
409 // type conversion for it. 404 // type conversion for it.
410 - else  
411 - { 405 + else {
412 QScopedPointer<Gallery> readColGallery(Gallery::make(colGallery)); 406 QScopedPointer<Gallery> readColGallery(Gallery::make(colGallery));
413 TemplateList templates = readColGallery->read(); 407 TemplateList templates = readColGallery->read();
414 QScopedPointer<Gallery> enrolledColOutput(Gallery::make(colEnrolledGallery)); 408 QScopedPointer<Gallery> enrolledColOutput(Gallery::make(colEnrolledGallery));
@@ -417,8 +411,7 @@ struct AlgorithmCore @@ -417,8 +411,7 @@ struct AlgorithmCore
417 } 411 }
418 412
419 // We have handled the column gallery, now decide whehter or not we have to enroll the row gallery. 413 // We have handled the column gallery, now decide whehter or not we have to enroll the row gallery.
420 - if (selfCompare)  
421 - { 414 + if (selfCompare) {
422 // For self-comparisons, we just use the already enrolled column set. 415 // For self-comparisons, we just use the already enrolled column set.
423 rowGallery = colEnrolledGallery; 416 rowGallery = colEnrolledGallery;
424 } 417 }
@@ -444,17 +437,15 @@ struct AlgorithmCore @@ -444,17 +437,15 @@ struct AlgorithmCore
444 // vector. 437 // vector.
445 QString compareRegionDesc; 438 QString compareRegionDesc;
446 if (this->galleryCompareString.isEmpty() ) 439 if (this->galleryCompareString.isEmpty() )
447 - compareRegionDesc = "Pipe([GalleryCompare("+Globals->algorithm + "," + colEnrolledGallery.flat() + ")])"; 440 + compareRegionDesc = "Pipe([GalleryCompare("+Globals->algorithm+")])";
448 else 441 else
449 - compareRegionDesc = "Pipe(["+this->galleryCompareString+"("+Globals->algorithm + "," + colEnrolledGallery.flat() + ")])"; 442 + compareRegionDesc = "Pipe(["+galleryCompareString+"])";
450 443
451 QScopedPointer<Transform> compareRegion; 444 QScopedPointer<Transform> compareRegion;
452 // If we need to enroll the row set, we add the current algorithm's enrollment transform before the 445 // If we need to enroll the row set, we add the current algorithm's enrollment transform before the
453 // GalleryCompare in a pipe. 446 // GalleryCompare in a pipe.
454 - if (needEnrollRows)  
455 - {  
456 - if (!multiProcess)  
457 - { 447 + if (needEnrollRows) {
  448 + if (!multiProcess) {
458 compareRegionDesc = compareRegionDesc; 449 compareRegionDesc = compareRegionDesc;
459 compareRegion.reset(Transform::make(compareRegionDesc,NULL)); 450 compareRegion.reset(Transform::make(compareRegionDesc,NULL));
460 CompositeTransform *downcast = dynamic_cast<CompositeTransform *> (compareRegion.data()); 451 CompositeTransform *downcast = dynamic_cast<CompositeTransform *> (compareRegion.data());
@@ -464,8 +455,7 @@ struct AlgorithmCore @@ -464,8 +455,7 @@ struct AlgorithmCore
464 downcast->transforms.prepend(this->transform.data()); 455 downcast->transforms.prepend(this->transform.data());
465 downcast->init(); 456 downcast->init();
466 } 457 }
467 - else  
468 - { 458 + else {
469 compareRegionDesc = "ProcessWrapper(" + this->transformString + "+" + compareRegionDesc + ")"; 459 compareRegionDesc = "ProcessWrapper(" + this->transformString + "+" + compareRegionDesc + ")";
470 compareRegion.reset(Transform::make(compareRegionDesc, NULL)); 460 compareRegion.reset(Transform::make(compareRegionDesc, NULL));
471 } 461 }
@@ -479,8 +469,7 @@ struct AlgorithmCore @@ -479,8 +469,7 @@ struct AlgorithmCore
479 // At this point, compareRegion is a transform, which optionally does enrollment, then compares the row 469 // At this point, compareRegion is a transform, which optionally does enrollment, then compares the row
480 // set against the column set. If in multi-process mode, the enrollment and comparison are wrapped in a 470 // set against the column set. If in multi-process mode, the enrollment and comparison are wrapped in a
481 // ProcessWrapper transform, and will be transparently run in multiple processes. 471 // ProcessWrapper transform, and will be transparently run in multiple processes.
482 - compareRegion->init();  
483 - 472 + compareRegion->setPropertyRecursive("galleryName", colEnrolledGallery.flat());
484 473
485 // We also need to add Output and progress counting to the algorithm we are building, so we will assign them to 474 // We also need to add Output and progress counting to the algorithm we are building, so we will assign them to
486 // two stages of a pipe. 475 // two stages of a pipe.
openbr/plugins/pp5.cpp
@@ -445,9 +445,7 @@ class PP5GalleryTransform: public UntrainableMetaTransform @@ -445,9 +445,7 @@ class PP5GalleryTransform: public UntrainableMetaTransform
445 , public PP5Context 445 , public PP5Context
446 { 446 {
447 Q_OBJECT 447 Q_OBJECT
448 - Q_PROPERTY(QString junk READ get_junk WRITE set_junk RESET reset_junk STORED false)  
449 Q_PROPERTY(QString galleryName READ get_galleryName WRITE set_galleryName RESET reset_galleryName STORED false) 448 Q_PROPERTY(QString galleryName READ get_galleryName WRITE set_galleryName RESET reset_galleryName STORED false)
450 - BR_PROPERTY(QString, junk, "")  
451 BR_PROPERTY(QString, galleryName, "") 449 BR_PROPERTY(QString, galleryName, "")
452 450
453 ppr_gallery_type target; 451 ppr_gallery_type target;