MainWindow.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. #include "MainWindow.hpp"
  2. #include "ImageHasher.hpp"
  3. #include <QDir>
  4. #include <QDirIterator>
  5. #include <QFile>
  6. #include <QFileDialog>
  7. #include <QFileInfo>
  8. #include <QHBoxLayout>
  9. #include <QMessageBox>
  10. #include <QPixmap>
  11. #include <QVBoxLayout>
  12. #include <chrono>
  13. #include <filesystem>
  14. #include <QAction>
  15. #include <QApplication>
  16. #include <QClipboard>
  17. #include <QContextMenuEvent>
  18. #include <QCoreApplication>
  19. #include <QDesktopServices>
  20. #include <QImageReader>
  21. #include <QMenu>
  22. #include <QPointer>
  23. #include <QSettings>
  24. #include <QStandardPaths>
  25. #include <QUrl>
  26. #include <QtConcurrent>
  27. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
  28. QString dataPath =
  29. QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
  30. if (!QDir().exists(dataPath)) {
  31. QDir().mkpath(dataPath);
  32. }
  33. QString dbPath = dataPath + "/dupfind_cache.db";
  34. m_dbManager = std::make_unique<DatabaseManager>(dbPath.toStdString());
  35. m_dbManager->open();
  36. m_scanWatcher = new QFutureWatcher<void>(this);
  37. m_searchWatcher = new QFutureWatcher<std::vector<DuplicateGroup>>(this);
  38. m_searchTimer = new QTimer(this);
  39. m_searchTimer->setSingleShot(true);
  40. m_searchTimer->setInterval(300);
  41. connect(m_searchTimer, &QTimer::timeout, this,
  42. &MainWindow::performAsyncSearch);
  43. connect(m_searchWatcher,
  44. &QFutureWatcher<std::vector<DuplicateGroup>>::finished, this,
  45. &MainWindow::onSearchFinished);
  46. // スタイルの適用
  47. QFile styleFile("resources/style.qss");
  48. if (styleFile.open(QFile::ReadOnly)) {
  49. QString styleSheet = QLatin1String(styleFile.readAll());
  50. setStyleSheet(styleSheet);
  51. }
  52. loadSettings(); // setupUi の前に読み込む
  53. setupUi();
  54. }
  55. MainWindow::~MainWindow() {}
  56. std::vector<ImageData> MainWindow::getFilteredImages() {
  57. auto allImages = m_dbManager->getAllImages();
  58. if (m_dirList->count() == 0)
  59. return {};
  60. std::vector<ImageData> filtered;
  61. for (const auto &img : allImages) {
  62. bool match = false;
  63. for (int i = 0; i < m_dirList->count(); ++i) {
  64. std::string dirPath = m_dirList->item(i)->text().toStdString();
  65. std::string dirPathWithSlash = dirPath;
  66. if (!dirPathWithSlash.empty() && dirPathWithSlash.back() != '/' &&
  67. dirPathWithSlash.back() != '\\') {
  68. dirPathWithSlash += "/";
  69. }
  70. if (img.path.find(dirPathWithSlash) == 0 || img.path == dirPath) {
  71. match = true;
  72. break;
  73. }
  74. }
  75. if (match && m_ignoredPaths.find(img.path) == m_ignoredPaths.end()) {
  76. filtered.push_back(img);
  77. }
  78. }
  79. return filtered;
  80. }
  81. void MainWindow::setupUi() {
  82. auto *central = new QWidget();
  83. auto *mainLayout = new QVBoxLayout(central);
  84. // Toolbar-like top section
  85. auto *toolLayout = new QHBoxLayout();
  86. m_addDirBtn = new QPushButton("Add Directory");
  87. m_removeDirBtn = new QPushButton("Remove Selected");
  88. m_startScanBtn = new QPushButton("Start Scan");
  89. m_deleteBtn = new QPushButton("Delete Selected Duplicates");
  90. m_deleteBtn->setObjectName("deleteBtn"); // QSS で赤くするため
  91. toolLayout->addWidget(m_addDirBtn);
  92. toolLayout->addWidget(m_removeDirBtn);
  93. toolLayout->addStretch();
  94. // Slider section
  95. toolLayout->addWidget(new QLabel("Similarity Threshold:"));
  96. m_thresholdSlider = new QSlider(Qt::Horizontal);
  97. m_thresholdSlider->setRange(0, 32);
  98. m_thresholdSlider->setValue(m_currentThreshold);
  99. m_thresholdSlider->setFixedWidth(150);
  100. m_thresholdLabel = new QLabel(QString::number(m_currentThreshold));
  101. toolLayout->addWidget(m_thresholdSlider);
  102. toolLayout->addWidget(m_thresholdLabel);
  103. m_strictCheckBox = new QCheckBox("Strict");
  104. m_strictCheckBox->setChecked(m_strictMode);
  105. toolLayout->addWidget(m_strictCheckBox);
  106. toolLayout->addWidget(m_startScanBtn);
  107. m_clearBtn = new QPushButton("Clear Results");
  108. toolLayout->addWidget(m_clearBtn);
  109. m_deselectBtn = new QPushButton("Deselect All");
  110. toolLayout->addWidget(m_deselectBtn);
  111. toolLayout->addWidget(m_deleteBtn);
  112. mainLayout->addLayout(toolLayout);
  113. // Split view
  114. auto *splitLayout = new QHBoxLayout();
  115. // Directory List
  116. m_dirList = new QListWidget();
  117. m_dirList->setMaximumWidth(250);
  118. // m_dirList->addItems(m_loadedDirs); // ここで復元
  119. for (const QString &dir : m_loadedDirs) {
  120. auto *item = new QListWidgetItem(dir, m_dirList);
  121. item->setToolTip(dir);
  122. }
  123. splitLayout->addWidget(m_dirList);
  124. // Results section (Search box + List View)
  125. auto *resultLayout = new QVBoxLayout();
  126. m_searchBox = new QLineEdit();
  127. m_searchBox->setPlaceholderText(
  128. "Filter results by path or filename... (Press Esc to close)");
  129. m_searchBox->setVisible(false);
  130. resultLayout->addWidget(m_searchBox);
  131. // Results List View
  132. m_resultView = new QListView();
  133. m_model = new ResultListModel(this);
  134. m_proxyModel = new ResultFilterProxyModel(this);
  135. m_proxyModel->setSourceModel(m_model);
  136. m_delegate = new ResultItemDelegate(this);
  137. m_resultView->setModel(m_proxyModel);
  138. m_resultView->setItemDelegate(m_delegate);
  139. m_resultView->setSelectionMode(QAbstractItemView::NoSelection);
  140. m_resultView->setSpacing(5);
  141. m_resultView->installEventFilter(this);
  142. m_searchBox->installEventFilter(this);
  143. resultLayout->addWidget(m_resultView);
  144. splitLayout->addLayout(resultLayout);
  145. mainLayout->addLayout(splitLayout);
  146. // Progress Bar
  147. m_progressBar = new QProgressBar();
  148. m_progressBar->setVisible(false);
  149. mainLayout->addWidget(m_progressBar);
  150. setCentralWidget(central);
  151. // Connections
  152. connect(m_addDirBtn, &QPushButton::clicked, this,
  153. &MainWindow::onAddDirectory);
  154. connect(m_removeDirBtn, &QPushButton::clicked, this,
  155. &MainWindow::onRemoveDirectory);
  156. connect(m_startScanBtn, &QPushButton::clicked, this,
  157. &MainWindow::onStartScan);
  158. connect(m_searchBox, &QLineEdit::textChanged, this,
  159. &MainWindow::onSearchTextChanged);
  160. connect(m_clearBtn, &QPushButton::clicked, this, &MainWindow::onClearResults);
  161. connect(m_deselectBtn, &QPushButton::clicked, this,
  162. [this]() { m_model->clearAllChecks(); });
  163. connect(m_deleteBtn, &QPushButton::clicked, this,
  164. &MainWindow::onDeleteSelected);
  165. connect(m_thresholdSlider, &QSlider::valueChanged, this,
  166. &MainWindow::onThresholdChanged);
  167. connect(m_strictCheckBox, &QCheckBox::stateChanged, this,
  168. &MainWindow::onStrictChanged);
  169. connect(m_scanWatcher, &QFutureWatcher<void>::finished, this,
  170. &MainWindow::onScanFinished);
  171. connect(m_delegate, &ResultItemDelegate::contextMenuRequested, this,
  172. &MainWindow::onContextMenuRequested);
  173. connect(m_delegate, &ResultItemDelegate::fileDoubleClicked, this,
  174. &MainWindow::onFileDoubleClicked);
  175. }
  176. void MainWindow::loadSettings() {
  177. // QString iniPath = QCoreApplication::applicationDirPath() + "/DupFind.ini";
  178. QString dataPath =
  179. QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
  180. if (!QDir().exists(dataPath)) {
  181. QDir().mkpath(dataPath);
  182. }
  183. QString iniPath = dataPath + "/settings.ini";
  184. QSettings settings(iniPath, QSettings::IniFormat);
  185. m_currentThreshold = settings.value("threshold", 5).toInt();
  186. m_strictMode = settings.value("strict_mode", false).toBool();
  187. m_loadedDirs = settings.value("directories").toStringList();
  188. }
  189. void MainWindow::saveSettings() {
  190. // QString iniPath = QCoreApplication::applicationDirPath() + "/DupFind.ini";
  191. QString dataPath =
  192. QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
  193. if (!QDir().exists(dataPath)) {
  194. QDir().mkpath(dataPath);
  195. }
  196. QString iniPath = dataPath + "/settings.ini";
  197. QSettings settings(iniPath, QSettings::IniFormat);
  198. settings.setValue("threshold", m_currentThreshold);
  199. settings.setValue("strict_mode", m_strictMode);
  200. QStringList dirs;
  201. for (int i = 0; i < m_dirList->count(); ++i) {
  202. dirs << m_dirList->item(i)->text();
  203. }
  204. settings.setValue("directories", dirs);
  205. }
  206. void MainWindow::closeEvent(QCloseEvent *event) {
  207. saveSettings();
  208. QMainWindow::closeEvent(event);
  209. }
  210. void MainWindow::onAddDirectory() {
  211. QString dir =
  212. QFileDialog::getExistingDirectory(this, "Select Directory to Scan");
  213. if (!dir.isEmpty()) {
  214. auto *item = new QListWidgetItem(dir, m_dirList);
  215. item->setToolTip(dir);
  216. saveSettings();
  217. }
  218. }
  219. void MainWindow::onRemoveDirectory() {
  220. auto *item = m_dirList->currentItem();
  221. if (item) {
  222. QString dirPath = item->text();
  223. m_dbManager->setDirectorySearchedStatus(dirPath.toStdString(), false);
  224. delete item;
  225. // キャッシュ再読み込み
  226. m_lastScannedImages = getFilteredImages();
  227. saveSettings();
  228. }
  229. }
  230. // 「Start Scan」ボタン押下時の処理
  231. // 選択されたディレクトリを再帰的に走査し、並列処理によって高速に画像ハッシュを分散計算し、DB保存する
  232. void MainWindow::onStartScan() {
  233. if (m_dirList->count() == 0) {
  234. QMessageBox::warning(this, "No Directory",
  235. "Please add at least one directory to scan.");
  236. return;
  237. }
  238. m_progressBar->setVisible(true);
  239. m_progressBar->setRange(0, 0); // 準備中
  240. m_startScanBtn->setEnabled(false);
  241. // 1. スキャン対象ディレクトリの収集
  242. std::vector<QString> dirPaths;
  243. for (int i = 0; i < m_dirList->count(); ++i) {
  244. dirPaths.push_back(m_dirList->item(i)->text());
  245. }
  246. // キャッシュ(DBの既存データ)を読み込み
  247. auto cachedList = m_dbManager->getAllImages();
  248. std::unordered_map<std::string, ImageData> cache;
  249. for (const auto &img : cachedList) {
  250. cache[img.path] = img;
  251. }
  252. // 2. 非同期で一連の処理を実行
  253. auto future = QtConcurrent::run([this, dirPaths, cache]() {
  254. // 全ファイルパスをリストアップ
  255. std::vector<std::string> allFiles;
  256. const QStringList filters = {"*.jpg", "*.png", "*.jpeg", "*.bmp",
  257. "*.webp", "*.tiff", "*.heic", "*.heif"};
  258. for (const auto &dirPath : dirPaths) {
  259. QDirIterator it(dirPath, filters, QDir::Files | QDir::NoSymLinks,
  260. QDirIterator::Subdirectories);
  261. while (it.hasNext()) {
  262. allFiles.push_back(it.next().toStdString());
  263. }
  264. }
  265. // 3. 並列ハッシュ計算 (mapped)
  266. auto processFunc = [&cache](const std::string &stdPath) -> ImageData {
  267. try {
  268. std::error_code ec;
  269. auto currentSize = std::filesystem::file_size(stdPath, ec);
  270. auto currentMtime = std::chrono::duration_cast<std::chrono::seconds>(
  271. std::filesystem::last_write_time(stdPath, ec)
  272. .time_since_epoch())
  273. .count();
  274. auto it = cache.find(stdPath);
  275. if (it != cache.end()) {
  276. if (it->second.file_size == static_cast<int64_t>(currentSize) &&
  277. it->second.timestamp == static_cast<int64_t>(currentMtime)) {
  278. return {}; // キャッシュと一致する場合はDBの再書き込みを避けるため空を返す
  279. }
  280. }
  281. cv::Mat img = ImageHasher::loadImage(stdPath);
  282. ImageData data;
  283. data.path = stdPath;
  284. data.is_searched = false;
  285. if (!img.empty()) {
  286. data.dhash = ImageHasher::calculateDHash(img);
  287. data.phash = ImageHasher::calculatePHash(img);
  288. }
  289. data.timestamp = currentMtime;
  290. data.file_size = currentSize;
  291. return data;
  292. } catch (...) {
  293. return {};
  294. }
  295. };
  296. // 並列実行
  297. auto results = QtConcurrent::blockingMapped(allFiles, processFunc);
  298. // 4. DBへの一括保存 (メインスレッドの管理外のDB接続で行う)
  299. QString dataPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
  300. QString dbPath = dataPath + "/dupfind_cache.db";
  301. DatabaseManager db(dbPath.toStdString());
  302. if (db.open()) {
  303. db.cleanupStaleEntries(); // DBに存在して実体がないファイルを削除
  304. db.beginTransaction();
  305. for (const auto &data : results) {
  306. if (data.path.empty())
  307. continue; // 全く変更がないファイルはスキップ
  308. db.addImage(data);
  309. }
  310. db.commitTransaction();
  311. }
  312. });
  313. m_scanWatcher->setFuture(future);
  314. }
  315. void MainWindow::onScanFinished() {
  316. m_startScanBtn->setEnabled(true);
  317. auto images = getFilteredImages();
  318. m_lastScannedImages = images; // キャッシュを更新
  319. // スキャン後は同期処理で固まらないように非同期検索を起動する
  320. performAsyncSearch();
  321. }
  322. void MainWindow::onThresholdChanged(int value) {
  323. m_currentThreshold = value;
  324. m_thresholdLabel->setText(QString::number(value));
  325. // フリーズして強制終了しても次回起動時に閾値が復元されるように保存
  326. saveSettings();
  327. // 操作が止まるまで待機(デバウンス)
  328. m_searchTimer->start();
  329. }
  330. void MainWindow::onStrictChanged(int state) {
  331. m_strictMode = (state == Qt::Checked);
  332. m_searchTimer->start();
  333. }
  334. // ハミング距離などに基づき、メモリ上の全画像データから重複グループを非同期で抽出・クラスタリングする
  335. void MainWindow::performAsyncSearch() {
  336. if (m_lastScannedImages.empty()) {
  337. m_lastScannedImages = getFilteredImages();
  338. }
  339. if (m_lastScannedImages.empty())
  340. return;
  341. m_progressBar->setVisible(true);
  342. m_progressBar->setRange(0, 0);
  343. m_progressBar->setFormat("Searching duplicates... %p%");
  344. // 現在実行中の検索があればキャンセルはできないが、WatcherのFutureを上書きすることで最新のみを追う
  345. auto future = QtConcurrent::run([images = m_lastScannedImages,
  346. threshold = m_currentThreshold,
  347. strict = m_strictMode]() {
  348. return SimilaritySearch::findDuplicates(images, threshold, strict);
  349. });
  350. m_searchWatcher->setFuture(future);
  351. }
  352. void MainWindow::onSearchFinished() {
  353. m_progressBar->setVisible(false);
  354. m_currentGroups = m_searchWatcher->result();
  355. updateResultGrid(m_currentGroups);
  356. // サムネイルが表示された時点で検索対象ディレクトリ群を検索済みとする
  357. for (int i = 0; i < m_dirList->count(); ++i) {
  358. QString dirPath = m_dirList->item(i)->text();
  359. m_dbManager->setDirectorySearchedStatus(dirPath.toStdString(), true);
  360. }
  361. // メモリ上のキャッシュも更新する
  362. m_lastScannedImages = getFilteredImages();
  363. }
  364. void MainWindow::removeGroupFromView(int groupId) {
  365. if (groupId >= 0 && groupId < static_cast<int>(m_currentGroups.size())) {
  366. for (const auto &img : m_currentGroups[groupId].images) {
  367. m_ignoredPaths.insert(img.path);
  368. }
  369. m_lastScannedImages = getFilteredImages();
  370. m_currentGroups.erase(m_currentGroups.begin() + groupId);
  371. updateResultGrid(m_currentGroups, true);
  372. }
  373. }
  374. void MainWindow::onClearResults() { m_model->clear(); }
  375. bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
  376. if (event->type() == QEvent::KeyPress) {
  377. QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
  378. if (obj == m_resultView) {
  379. if ((keyEvent->modifiers() & Qt::ControlModifier) &&
  380. keyEvent->key() == Qt::Key_F) {
  381. m_searchBox->setVisible(true);
  382. m_searchBox->setFocus();
  383. return true;
  384. } else if (keyEvent->key() == Qt::Key_F &&
  385. keyEvent->modifiers() == Qt::NoModifier) {
  386. m_searchBox->setVisible(true);
  387. m_searchBox->setFocus();
  388. return true;
  389. }
  390. } else if (obj == m_searchBox) {
  391. if (keyEvent->key() == Qt::Key_Escape) {
  392. m_searchBox->clear();
  393. m_searchBox->setVisible(false);
  394. m_resultView->setFocus();
  395. return true;
  396. }
  397. }
  398. }
  399. return QMainWindow::eventFilter(obj, event);
  400. }
  401. void MainWindow::onSearchTextChanged(const QString &text) {
  402. if (m_proxyModel) {
  403. m_proxyModel->setSearchText(text);
  404. }
  405. }
  406. void MainWindow::onFileDoubleClicked(const std::string &path) {
  407. if (!path.empty()) {
  408. QDesktopServices::openUrl(
  409. QUrl::fromLocalFile(QString::fromStdString(path)));
  410. }
  411. }
  412. void MainWindow::onContextMenuRequested(const std::string &path, int groupId,
  413. const QPoint &globalPos) {
  414. if (!path.empty()) {
  415. QMenu menu;
  416. QAction *copyAction = menu.addAction("Copy Full Path(&C)");
  417. menu.addSeparator();
  418. QAction *removeAction = menu.addAction("Remove from List(&R)");
  419. QAction *selectedAction = menu.exec(globalPos);
  420. if (selectedAction == copyAction) {
  421. QApplication::clipboard()->setText(QString::fromStdString(path));
  422. } else if (selectedAction == removeAction) {
  423. removeGroupFromView(groupId);
  424. }
  425. }
  426. }
  427. // 同一・類似と判定された画像のグループを受け取り、UI上のグリッドレイアウトへ動的にサムネイルと削除候補のチェックボックスを描画する
  428. void MainWindow::updateResultGrid(const std::vector<DuplicateGroup> &groups,
  429. bool preserveState) {
  430. m_model->setGroups(groups, preserveState);
  431. }
  432. void MainWindow::onDeleteSelected() {
  433. std::unordered_set<int> visibleGroupIds;
  434. for (int i = 0; i < m_proxyModel->rowCount(); ++i) {
  435. QModelIndex proxyIndex = m_proxyModel->index(i, 0);
  436. QModelIndex sourceIndex = m_proxyModel->mapToSource(proxyIndex);
  437. const auto &item = m_model->getItem(sourceIndex.row());
  438. if (item.type == ResultListItem::Header) {
  439. visibleGroupIds.insert(item.groupId);
  440. }
  441. }
  442. int count = 0;
  443. std::map<int, int> groupTotalCount;
  444. std::map<int, int> groupCheckedCount;
  445. std::vector<std::string> pathsToDelete;
  446. const auto &checkStates = m_model->getCheckStates();
  447. int groupId = 0;
  448. for (const auto &group : m_currentGroups) {
  449. if (visibleGroupIds.find(groupId) != visibleGroupIds.end()) {
  450. for (const auto &img : group.images) {
  451. groupTotalCount[groupId]++;
  452. auto it = checkStates.find(img.path);
  453. if (it != checkStates.end() && it->second) {
  454. groupCheckedCount[groupId]++;
  455. count++;
  456. pathsToDelete.push_back(img.path);
  457. }
  458. }
  459. }
  460. groupId++;
  461. }
  462. if (count == 0)
  463. return;
  464. bool allCheckedInSomeGroup = false;
  465. for (auto const &[gId, total] : groupTotalCount) {
  466. if (groupCheckedCount[gId] == total && total > 0) {
  467. allCheckedInSomeGroup = true;
  468. break;
  469. }
  470. }
  471. if (allCheckedInSomeGroup) {
  472. auto warnRes = QMessageBox::warning(
  473. this, "Warning: All images selected",
  474. "一部の類似画像グループで、すべての画像が削除対象としてチェックされてい"
  475. "ます。\n"
  476. "このまま削除すると、それらの画像ファイルはすべて失われます。\n\n"
  477. "本当に削除を実行しますか?",
  478. QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel);
  479. if (warnRes != QMessageBox::Ok) {
  480. return;
  481. }
  482. }
  483. auto res = QMessageBox::question(
  484. this, "Confirm Deletion",
  485. QString("Are you sure you want to move %1 images to Trash?").arg(count));
  486. if (res == QMessageBox::Yes) {
  487. std::vector<QString> failures;
  488. for (const auto &path : pathsToDelete) {
  489. QString qPath = QString::fromStdString(path);
  490. if (QFile::moveToTrash(qPath)) {
  491. m_dbManager->removeImage(path);
  492. } else {
  493. failures.push_back(qPath);
  494. }
  495. }
  496. if (!failures.empty()) {
  497. QString msg = "The following files could not be moved to trash and were "
  498. "NOT deleted:\n\n";
  499. for (const auto &f : failures) {
  500. msg += f + "\n";
  501. }
  502. QMessageBox::warning(this, "Deletion Error", msg);
  503. }
  504. // リストをリフレッシュ
  505. auto images = getFilteredImages();
  506. m_currentGroups = SimilaritySearch::findDuplicates(
  507. images, m_currentThreshold, m_strictMode);
  508. updateResultGrid(m_currentGroups);
  509. }
  510. }