MCPcopy Create free account
hub / github.com/biometrics/openbr / compare

Method compare

openbr/core/core.cpp:374–538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372 }
373
374 void compare(File targetGallery, File queryGallery, File output)
375 {
376 qDebug("Comparing %s and %s%s", qPrintable(targetGallery.flat()),
377 qPrintable(queryGallery.flat()),
378 output.isNull() ? "" : qPrintable(" to " + output.flat()));
379
380 // Escape hatch for distances that need to operate directly on the gallery files
381 if (distance && distance->compare(targetGallery, queryGallery, output))
382 return;
383
384 // Are we comparing the same gallery against itself?
385 bool selfCompare = targetGallery == queryGallery;
386
387 // Should we use multiple processes to do enrollment/comparison? If not, we just do multi-threading.
388 bool multiProcess = Globals->file.getBool("multiProcess", false);
389
390 // In comparing two galleries, we will keep the smaller one in memory, and load the larger one
391 // incrementally. If the gallery set is larger than the probe set, we operate in transpose mode
392 // i.e. we must transpose our output, to still write the output matrix in row-major order.
393 bool transposeMode = false;
394
395 // Is the larger gallery already enrolled? If not, we will enroll those images in-line with their
396 // comparison against the smaller gallery (which will be enrolled, and stored in memory).
397 bool needEnrollRows = false;
398
399 if (output.exists() && output.get<bool>("cache", false)) return;
400 if (queryGallery == ".") queryGallery = targetGallery;
401
402 // To decide which gallery is larger, we need to read both, but at this point we just want the
403 // metadata, and don't need the enrolled matrices.
404 FileList targetMetadata;
405 FileList queryMetadata;
406
407 // Emptyread reads a gallery, and discards any matrices present, keeping only the metadata.
408 targetMetadata = FileList::fromGallery(targetGallery, true);
409 queryMetadata = FileList::fromGallery(queryGallery, true);
410
411 // Is the target or query set larger? We will use the larger as the rows of our comparison matrix (and transpose the output if necessary)
412 transposeMode = targetMetadata.size() > queryMetadata.size();
413
414 File rowGallery = queryGallery;
415 File colGallery = targetGallery;
416 qint64 rowSize;
417
418 Gallery *temp;
419 if (transposeMode) {
420 rowGallery = targetGallery;
421 colGallery = queryGallery;
422 temp = Gallery::make(targetGallery);
423 }
424 else
425 temp = Gallery::make(queryGallery);
426
427 rowSize = temp->totalSize();
428 delete temp;
429
430 if (selfCompare)
431 rowSize = queryMetadata.size();

Callers 5

getFourccMethod · 0.45
pairwiseCompareMethod · 0.45
deduplicateMethod · 0.45
CompareMethod · 0.45
CompareTemplateListsMethod · 0.45

Calls 15

makeFunction · 0.85
TemplateClass · 0.85
flatMethod · 0.80
getBoolMethod · 0.80
get<bool>Method · 0.80
hashMethod · 0.80
isEmptyMethod · 0.80
isNullMethod · 0.45
sizeMethod · 0.45
totalSizeMethod · 0.45
containsMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected