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