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

Method deduplicate

openbr/core/core.cpp:324–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322 }
323
324 void deduplicate(const File &inputGallery, const File &outputGallery, const float threshold)
325 {
326 qDebug("Deduplicating %s to %s with a score threshold of %f", qPrintable(inputGallery.flat()), qPrintable(outputGallery.flat()), threshold);
327
328 if (distance.isNull()) qFatal("Null distance.");
329
330 QScopedPointer<Gallery> i;
331 FileList inputFiles;
332 retrieveOrEnroll(inputGallery, i, inputFiles);
333
334 TemplateList t = i->read();
335
336 Output *o = Output::make(QString("buffer.tail[selfSimilar,threshold=%1,atLeast=0]").arg(QString::number(threshold)),inputFiles,inputFiles);
337
338 // Compare to global tail output
339 distance->compare(t,t,o);
340
341 delete o;
342
343 QString buffer(Globals->buffer);
344
345 QStringList tail = buffer.split("\n");
346
347 // Remove header
348 tail.removeFirst();
349
350 QStringList toRemove;
351 foreach (const QString &s, tail)
352 toRemove.append(s.split(',').at(1));
353
354 QSet<QString> duplicates = QSet<QString>::fromList(toRemove);
355
356 QStringList fileNames = inputFiles.names();
357
358 QList<int> indices;
359 foreach (const QString &d, duplicates)
360 indices.append(fileNames.indexOf(d));
361
362 std::sort(indices.begin(),indices.end(),std::greater<float>());
363
364 qDebug("\n%d duplicates removed.", indices.size());
365
366 for (int i=0; i<indices.size(); i++)
367 inputFiles.removeAt(indices[i]);
368
369 QScopedPointer<Gallery> og(Gallery::make(outputGallery));
370
371 og->writeBlock(inputFiles);
372 }
373
374 void compare(File targetGallery, File queryGallery, File output)
375 {

Callers 1

DeduplicateMethod · 0.80

Calls 12

makeFunction · 0.85
flatMethod · 0.80
atMethod · 0.80
namesMethod · 0.80
endMethod · 0.80
isNullMethod · 0.45
readMethod · 0.45
compareMethod · 0.45
splitMethod · 0.45
appendMethod · 0.45
sizeMethod · 0.45
writeBlockMethod · 0.45

Tested by

no test coverage detected