Commit 33ec0cdc9cd7a7f78621f2a8bb5898fa0ae90e43

Authored by Charles Otto
1 parent c860d36e

Don't create temporary transforms containing idenity

Instead, we just prepend/append to transform lists as needed. Maybe this
is less confusing.
Showing 1 changed file with 13 additions and 13 deletions
openbr/core/core.cpp
... ... @@ -47,12 +47,12 @@ struct AlgorithmCore
47 47 qDebug("Training on %s%s", qPrintable(input.flat()),
48 48 model.isEmpty() ? "" : qPrintable(" to " + model));
49 49  
50   - QScopedPointer<Transform> trainingWrapper(Transform::make("DirectStream([Identity], readMode=DistributeFrames)", NULL));
  50 + QScopedPointer<Transform> trainingWrapper(Transform::make("DirectStream(readMode=DistributeFrames)", NULL));
51 51  
52 52 CompositeTransform * downcast = dynamic_cast<CompositeTransform *>(trainingWrapper.data());
53 53 if (downcast == NULL)
54 54 qFatal("downcast failed?");
55   - downcast->transforms[0] = this->transform.data();
  55 + downcast->transforms.append(this->transform.data());
56 56  
57 57 downcast->init();
58 58  
... ... @@ -163,14 +163,14 @@ struct AlgorithmCore
163 163  
164 164 if (!multiProcess)
165 165 {
166   - QString pipeDesc = "Identity+GalleryOutput("+gallery.flat()+")+ProgressCounter("+QString::number(data.length())+")+Discard";
  166 + QString pipeDesc = "GalleryOutput("+gallery.flat()+")+ProgressCounter("+QString::number(data.length())+")+Discard";
167 167 basePipe.reset(Transform::make(pipeDesc,NULL));
168 168 CompositeTransform * downcast = dynamic_cast<CompositeTransform *>(basePipe.data());
169 169 if (downcast == NULL)
170 170 qFatal("downcast failed?");
171 171  
172 172 // replace that placeholder with the current algorithm
173   - downcast->transforms[0] = this->transform.data();
  173 + downcast->transforms.prepend(this->transform.data());
174 174  
175 175 // call init on the pipe to collapse the algorithm (if its top level is a pipe)
176 176 downcast->init();
... ... @@ -182,7 +182,7 @@ struct AlgorithmCore
182 182 }
183 183  
184 184 // Next, we make a Stream (with placeholder transform)
185   - QString streamDesc = "Stream(Identity, readMode=DistributeFrames)";
  185 + QString streamDesc = "Stream(readMode=DistributeFrames)";
186 186 QScopedPointer<Transform> baseStream(Transform::make(streamDesc, NULL));
187 187 WrapperTransform * wrapper = dynamic_cast<WrapperTransform *> (baseStream.data());
188 188  
... ... @@ -428,7 +428,7 @@ struct AlgorithmCore
428 428 // The actual comparison step is done by a GalleryCompare transform, which has a Distance, and a gallery as data.
429 429 // Incoming templates are compared against the templates in the gallery, and the output is the resulting score
430 430 // vector.
431   - QString compareRegionDesc = "GalleryCompare("+Globals->algorithm + "," + colEnrolledGallery.flat() + ")";
  431 + QString compareRegionDesc = "Pipe([GalleryCompare("+Globals->algorithm + "," + colEnrolledGallery.flat() + ")])";
432 432  
433 433  
434 434 QScopedPointer<Transform> compareRegion;
... ... @@ -438,13 +438,13 @@ struct AlgorithmCore
438 438 {
439 439 if (!multiProcess)
440 440 {
441   - compareRegionDesc = "Identity+" + compareRegionDesc;
  441 + compareRegionDesc = compareRegionDesc;
442 442 compareRegion.reset(Transform::make(compareRegionDesc,NULL));
443 443 CompositeTransform * downcast = dynamic_cast<CompositeTransform *> (compareRegion.data());
444 444 if (downcast == NULL)
445 445 qFatal("Pipe downcast failed in compare");
446 446  
447   - downcast->transforms[0] = this->transform.data();
  447 + downcast->transforms.prepend(this->transform.data());
448 448 downcast->init();
449 449 }
450 450 else
... ... @@ -467,7 +467,7 @@ struct AlgorithmCore
467 467  
468 468 // We also need to add Output and progress counting to the algorithm we are building, so we will assign them to
469 469 // two stages of a pipe.
470   - QString joinDesc = "Identity+Identity";
  470 + QString joinDesc = "Pipe()";
471 471 QScopedPointer<Transform> join(Transform::make(joinDesc, NULL));
472 472  
473 473 // The output transform takes the metadata memGalleries we set up previously as input, along with the
... ... @@ -481,8 +481,8 @@ struct AlgorithmCore
481 481 // Assign the comparison transform we previously built, and the output transform we just built to
482 482 // two stages of a pipe.
483 483 CompositeTransform * downcast = dynamic_cast<CompositeTransform *> (join.data());
484   - downcast->transforms[0] = compareRegion.data();
485   - downcast->transforms[1] = outputTform.data();
  484 + downcast->transforms.append(compareRegion.data());
  485 + downcast->transforms.append(outputTform.data());
486 486  
487 487 // With this, we have set up a transform which (optionally) enrolls templates, compares them
488 488 // against a gallery, and outputs them.
... ... @@ -490,7 +490,7 @@ struct AlgorithmCore
490 490  
491 491 // Now, we will give that base transform to a stream, which will incrementally read the row gallery
492 492 // and pass the transforms it reads through the base algorithm.
493   - QString streamDesc = "Stream(Identity, readMode=StreamGallery)";
  493 + QString streamDesc = "Stream(readMode=StreamGallery)";
494 494 QScopedPointer<Transform> streamBase(Transform::make(streamDesc, NULL));
495 495 WrapperTransform * streamWrapper = dynamic_cast<WrapperTransform *> (streamBase.data());
496 496 streamWrapper->transform = join.data();
... ... @@ -706,7 +706,7 @@ QSharedPointer&lt;br::Transform&gt; br::Transform::fromAlgorithm(const QString &amp;algori
706 706 return AlgorithmManager::getAlgorithm(algorithm)->transform;
707 707 else {
708 708 QSharedPointer<Transform> orig_tform = AlgorithmManager::getAlgorithm(algorithm)->transform;
709   - QSharedPointer<Transform> newRoot = QSharedPointer<Transform>(Transform::make("Stream(Identity, readMode=DistributeFrames)", NULL));
  709 + QSharedPointer<Transform> newRoot = QSharedPointer<Transform>(Transform::make("Stream(readMode=DistributeFrames)", NULL));
710 710 WrapperTransform * downcast = dynamic_cast<WrapperTransform *> (newRoot.data());
711 711 downcast->transform = orig_tform.data();
712 712 downcast->init();
... ...