[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [digikam] core/utilities/facemanagement: move scan state filter implementation in a dedicated .h/.cp
From: Gilles Caulier <null () kde ! org>
Date: 2018-09-20 5:45:35
Message-ID: E1g2rmR-00042N-8j () code ! kde ! org
[Download RAW message or body]
Git commit 9567c1e9beeb88eacf213557002ac6fa371bb019 by Gilles Caulier.
Committed on 20/09/2018 at 05:44.
Pushed by cgilles into branch 'master'.
move scan state filter implementation in a dedicated .h/.cpp
M +1 -0 core/utilities/facemanagement/CMakeLists.txt
M +12 -0 core/utilities/facemanagement/facepipeline.cpp
M +2 -4 core/utilities/facemanagement/facepipeline.h
M +1 -166 core/utilities/facemanagement/facepipeline_p.cpp
M +1 -40 core/utilities/facemanagement/facepipeline_p.h
A +217 -0 core/utilities/facemanagement/scanstatefilter.cpp [License: GPL \
(v2+)] A +87 -0 core/utilities/facemanagement/scanstatefilter.h [License: \
GPL (v2+)]
https://commits.kde.org/digikam/9567c1e9beeb88eacf213557002ac6fa371bb019
diff --git a/core/utilities/facemanagement/CMakeLists.txt \
b/core/utilities/facemanagement/CMakeLists.txt index f7fbf5b5bb..19ea539c22 100644
--- a/core/utilities/facemanagement/CMakeLists.txt
+++ b/core/utilities/facemanagement/CMakeLists.txt
@@ -20,6 +20,7 @@ set(libfacemanagement_SRCS
facescandialog.cpp
assignnamewidget.cpp
parallelpipes.cpp
+ scanstatefilter.cpp
)
include_directories($<TARGET_PROPERTY:Qt5::Sql,INTERFACE_INCLUDE_DIRECTORIES>
diff --git a/core/utilities/facemanagement/facepipeline.cpp \
b/core/utilities/facemanagement/facepipeline.cpp index d258771d53..1c96a2c93d 100644
--- a/core/utilities/facemanagement/facepipeline.cpp
+++ b/core/utilities/facemanagement/facepipeline.cpp
@@ -46,6 +46,7 @@
#include "faceworkers.h"
#include "faceimageretriever.h"
#include "parallelpipes.h"
+#include "scanstatefilter.h"
namespace Digikam
{
@@ -142,6 +143,17 @@ FacePipelineFaceTagsIfaceList \
FacePipelineFaceTagsIfaceList::facesForRole(FacePi
// -----------------------------------------------------------------------------------------
+FacePipelinePackage::FacePipelinePackage()
+ : processFlags(NotProcessed)
+{
+}
+
+FacePipelinePackage::~FacePipelinePackage()
+{
+}
+
+// -----------------------------------------------------------------------------------------
+
FacePipeline::FacePipeline()
: d(new Private(this))
{
diff --git a/core/utilities/facemanagement/facepipeline.h \
b/core/utilities/facemanagement/facepipeline.h index 65de2534c3..87cb3d9929 100644
--- a/core/utilities/facemanagement/facepipeline.h
+++ b/core/utilities/facemanagement/facepipeline.h
@@ -120,10 +120,8 @@ public:
public:
- FacePipelinePackage()
- : processFlags(NotProcessed)
- {
- }
+ explicit FacePipelinePackage();
+ ~FacePipelinePackage();
public:
diff --git a/core/utilities/facemanagement/facepipeline_p.cpp \
b/core/utilities/facemanagement/facepipeline_p.cpp index 9c75d59679..087390520e \
100644
--- a/core/utilities/facemanagement/facepipeline_p.cpp
+++ b/core/utilities/facemanagement/facepipeline_p.cpp
@@ -45,6 +45,7 @@
#include "faceworkers.h"
#include "faceimageretriever.h"
#include "parallelpipes.h"
+#include "scanstatefilter.h"
namespace Digikam
{
@@ -69,172 +70,6 @@ FacePipelineExtendedPackage::Ptr \
PackageLoadingDescriptionList::take(const Loadi
// ----------------------------------------------------------------------------------------
-ScanStateFilter::ScanStateFilter(FacePipeline::FilterMode mode, \
FacePipeline::Private* const d)
- : d(d),
- mode(mode)
-{
- connect(this, SIGNAL(infosToDispatch()),
- this, SLOT(dispatch()));
-}
-
-FacePipelineExtendedPackage::Ptr ScanStateFilter::filter(const ImageInfo& info)
-{
- FaceUtils utils;
-
- switch (mode)
- {
- case FacePipeline::ScanAll:
- {
- return d->buildPackage(info);
- }
-
- case FacePipeline::SkipAlreadyScanned:
- {
- if (!utils.hasBeenScanned(info))
- {
- return d->buildPackage(info);
- }
-
- break;
- }
-
- case FacePipeline::ReadUnconfirmedFaces:
- case FacePipeline::ReadFacesForTraining:
- case FacePipeline::ReadConfirmedFaces:
- {
- QList<FaceTagsIface> databaseFaces;
-
- if (mode == FacePipeline::ReadUnconfirmedFaces)
- {
- databaseFaces = utils.unconfirmedFaceTagsIfaces(info.id());
-
- }
- else if (mode == FacePipeline::ReadFacesForTraining)
- {
- databaseFaces = utils.databaseFacesForTraining(info.id());
- }
- else
- {
- databaseFaces = utils.confirmedFaceTagsIfaces(info.id());
- }
-
- if (!databaseFaces.isEmpty())
- {
- FacePipelineExtendedPackage::Ptr package = d->buildPackage(info);
- package->databaseFaces = databaseFaces;
- //qCDebug(DIGIKAM_GENERAL_LOG) << "Prepared package with" << \
databaseFaces.size();
- package->databaseFaces.setRole(FacePipelineFaceTagsIface::ReadFromDatabase);
-
- if (tasks)
- {
- package->databaseFaces.setRole(tasks);
- }
-
- return package;
- }
-
- break;
- }
- }
-
- return FacePipelineExtendedPackage::Ptr();
-}
-
-void ScanStateFilter::process(const QList<ImageInfo>& infos)
-{
- QMutexLocker lock(threadMutex());
- toFilter << infos;
- //qCDebug(DIGIKAM_GENERAL_LOG) << "Received" << infos.size() << "images for \
filtering";
- start(lock);
-}
-
-void ScanStateFilter::process(const ImageInfo& info)
-{
- QMutexLocker lock(threadMutex());
- toFilter << info;
- start(lock);
-}
-
-void ScanStateFilter::run()
-{
- while (runningFlag())
- {
- // get todo list
- QList<ImageInfo> todo;
- {
- QMutexLocker lock(threadMutex());
-
- if (!toFilter.isEmpty())
- {
- todo = toFilter;
- toFilter.clear();
- }
- else
- {
- stop(lock);
- }
- }
-
- // process list
- if (!todo.isEmpty())
- {
- QList<FacePipelineExtendedPackage::Ptr> send;
- QList<ImageInfo> skip;
-
- foreach (const ImageInfo& info, todo)
- {
- FacePipelineExtendedPackage::Ptr package = filter(info);
-
- if (package)
- {
- send << package;
- }
- else
- {
- skip << info;
- }
- }
-
- //qCDebug(DIGIKAM_GENERAL_LOG) << "Filtered" << todo.size() << "images, \
send" << send.size() << "skip" << skip.size();
-
- {
- QMutexLocker lock(threadMutex());
- toSend << send;
- toBeSkipped << skip;
- }
-
- emit infosToDispatch();
- }
- }
-}
-
-void ScanStateFilter::dispatch()
-{
- QList<FacePipelineExtendedPackage::Ptr> send;
-
- QList<ImageInfo> skip;
- {
- QMutexLocker lock(threadMutex());
- send = toSend;
- toSend.clear();
- skip = toBeSkipped;
- toBeSkipped.clear();
- }
-
- //qCDebug(DIGIKAM_GENERAL_LOG) << "Dispatching, sending" << send.size() << \
"skipping" << skip.size();
- if (!skip.isEmpty())
- {
- d->skipFromFilter(skip);
- }
-
- if (!send.isEmpty())
- {
- d->sendFromFilter(send);
- }
-}
-
-// ----------------------------------------------------------------------------------------
-
FacePipeline::Private::Private(FacePipeline* const q)
: q(q)
{
diff --git a/core/utilities/facemanagement/facepipeline_p.h \
b/core/utilities/facemanagement/facepipeline_p.h index 22d51b82e4..dc85b790b4 100644
--- a/core/utilities/facemanagement/facepipeline_p.h
+++ b/core/utilities/facemanagement/facepipeline_p.h
@@ -54,6 +54,7 @@ class DatabaseWriter;
class PreviewLoader;
class FaceImageRetriever;
class ParallelPipes;
+class ScanStateFilter;
class Q_DECL_HIDDEN FacePipelineExtendedPackage : public FacePipelinePackage,
public QSharedData
@@ -87,46 +88,6 @@ public:
// ----------------------------------------------------------------------------------------
-class Q_DECL_HIDDEN ScanStateFilter : public DynamicThread
-{
- Q_OBJECT
-
-public:
-
- ScanStateFilter(FacePipeline::FilterMode mode, FacePipeline::Private* const d);
-
- void process(const QList<ImageInfo>& infos);
- void process(const ImageInfo& info);
-
- FacePipelineExtendedPackage::Ptr filter(const ImageInfo& info);
-
-public:
-
- FacePipeline::Private* const d;
- FacePipeline::FilterMode mode;
- FacePipelineFaceTagsIface::Roles tasks;
-
-protected Q_SLOTS:
-
- void dispatch();
-
-Q_SIGNALS:
-
- void infosToDispatch();
-
-protected:
-
- virtual void run();
-
-protected:
-
- QList<ImageInfo> toFilter;
- QList<FacePipelineExtendedPackage::Ptr> toSend;
- QList<ImageInfo> toBeSkipped;
-};
-
-// ----------------------------------------------------------------------------------------
-
class Q_DECL_HIDDEN FacePipeline::Private : public QObject
{
Q_OBJECT
diff --git a/core/utilities/facemanagement/scanstatefilter.cpp \
b/core/utilities/facemanagement/scanstatefilter.cpp new file mode 100644
index 0000000000..cd31e9de77
--- /dev/null
+++ b/core/utilities/facemanagement/scanstatefilter.cpp
@@ -0,0 +1,217 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2010-09-03
+ * Description : Integrated, multithread face detection / recognition
+ *
+ * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#include "scanstatefilter.h"
+
+// Qt includes
+
+#include <QMetaObject>
+#include <QMutexLocker>
+
+// KDE includes
+
+#include <klocalizedstring.h>
+#include <ksharedconfig.h>
+#include <kconfiggroup.h>
+
+// Local includes
+
+#include "digikam_debug.h"
+#include "loadingdescription.h"
+#include "metadatasettings.h"
+#include "tagscache.h"
+#include "threadmanager.h"
+#include "facebenchmarkers.h"
+#include "faceworkers.h"
+#include "faceimageretriever.h"
+#include "parallelpipes.h"
+
+namespace Digikam
+{
+
+ScanStateFilter::ScanStateFilter(FacePipeline::FilterMode mode, \
FacePipeline::Private* const d) + : d(d),
+ mode(mode)
+{
+ connect(this, SIGNAL(infosToDispatch()),
+ this, SLOT(dispatch()));
+}
+
+FacePipelineExtendedPackage::Ptr ScanStateFilter::filter(const ImageInfo& info)
+{
+ FaceUtils utils;
+
+ switch (mode)
+ {
+ case FacePipeline::ScanAll:
+ {
+ return d->buildPackage(info);
+ }
+
+ case FacePipeline::SkipAlreadyScanned:
+ {
+ if (!utils.hasBeenScanned(info))
+ {
+ return d->buildPackage(info);
+ }
+
+ break;
+ }
+
+ case FacePipeline::ReadUnconfirmedFaces:
+ case FacePipeline::ReadFacesForTraining:
+ case FacePipeline::ReadConfirmedFaces:
+ {
+ QList<FaceTagsIface> databaseFaces;
+
+ if (mode == FacePipeline::ReadUnconfirmedFaces)
+ {
+ databaseFaces = utils.unconfirmedFaceTagsIfaces(info.id());
+
+ }
+ else if (mode == FacePipeline::ReadFacesForTraining)
+ {
+ databaseFaces = utils.databaseFacesForTraining(info.id());
+ }
+ else
+ {
+ databaseFaces = utils.confirmedFaceTagsIfaces(info.id());
+ }
+
+ if (!databaseFaces.isEmpty())
+ {
+ FacePipelineExtendedPackage::Ptr package = d->buildPackage(info);
+ package->databaseFaces = databaseFaces;
+ //qCDebug(DIGIKAM_GENERAL_LOG) << "Prepared package with" << \
databaseFaces.size(); + \
package->databaseFaces.setRole(FacePipelineFaceTagsIface::ReadFromDatabase); +
+ if (tasks)
+ {
+ package->databaseFaces.setRole(tasks);
+ }
+
+ return package;
+ }
+
+ break;
+ }
+ }
+
+ return FacePipelineExtendedPackage::Ptr();
+}
+
+void ScanStateFilter::process(const QList<ImageInfo>& infos)
+{
+ QMutexLocker lock(threadMutex());
+ toFilter << infos;
+ //qCDebug(DIGIKAM_GENERAL_LOG) << "Received" << infos.size() << "images for \
filtering"; + start(lock);
+}
+
+void ScanStateFilter::process(const ImageInfo& info)
+{
+ QMutexLocker lock(threadMutex());
+ toFilter << info;
+ start(lock);
+}
+
+void ScanStateFilter::run()
+{
+ while (runningFlag())
+ {
+ // get todo list
+ QList<ImageInfo> todo;
+ {
+ QMutexLocker lock(threadMutex());
+
+ if (!toFilter.isEmpty())
+ {
+ todo = toFilter;
+ toFilter.clear();
+ }
+ else
+ {
+ stop(lock);
+ }
+ }
+
+ // process list
+ if (!todo.isEmpty())
+ {
+ QList<FacePipelineExtendedPackage::Ptr> send;
+ QList<ImageInfo> skip;
+
+ foreach (const ImageInfo& info, todo)
+ {
+ FacePipelineExtendedPackage::Ptr package = filter(info);
+
+ if (package)
+ {
+ send << package;
+ }
+ else
+ {
+ skip << info;
+ }
+ }
+
+ //qCDebug(DIGIKAM_GENERAL_LOG) << "Filtered" << todo.size() << "images, \
send" << send.size() << "skip" << skip.size(); +
+ {
+ QMutexLocker lock(threadMutex());
+ toSend << send;
+ toBeSkipped << skip;
+ }
+
+ emit infosToDispatch();
+ }
+ }
+}
+
+void ScanStateFilter::dispatch()
+{
+ QList<FacePipelineExtendedPackage::Ptr> send;
+
+ QList<ImageInfo> skip;
+ {
+ QMutexLocker lock(threadMutex());
+ send = toSend;
+ toSend.clear();
+ skip = toBeSkipped;
+ toBeSkipped.clear();
+ }
+
+ //qCDebug(DIGIKAM_GENERAL_LOG) << "Dispatching, sending" << send.size() << \
"skipping" << skip.size(); +
+ if (!skip.isEmpty())
+ {
+ d->skipFromFilter(skip);
+ }
+
+ if (!send.isEmpty())
+ {
+ d->sendFromFilter(send);
+ }
+}
+
+} // namespace Digikam
diff --git a/core/utilities/facemanagement/scanstatefilter.h \
b/core/utilities/facemanagement/scanstatefilter.h new file mode 100644
index 0000000000..db2b30be06
--- /dev/null
+++ b/core/utilities/facemanagement/scanstatefilter.h
@@ -0,0 +1,87 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2010-09-03
+ * Description : Integrated, multithread face detection / recognition
+ *
+ * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef DIGIKAM_SCAN_STATE_FILTER_H
+#define DIGIKAM_SCAN_STATE_FILTER_H
+
+// Qt includes
+
+#include <QExplicitlySharedDataPointer>
+#include <QMetaMethod>
+#include <QMutex>
+#include <QSharedData>
+#include <QWaitCondition>
+
+// Local includes
+
+#include "facepipeline_p.h"
+#include "facedetector.h"
+#include "faceutils.h"
+#include "previewloadthread.h"
+#include "thumbnailloadthread.h"
+#include "workerobject.h"
+
+namespace Digikam
+{
+
+class Q_DECL_HIDDEN ScanStateFilter : public DynamicThread
+{
+ Q_OBJECT
+
+public:
+
+ ScanStateFilter(FacePipeline::FilterMode mode, FacePipeline::Private* const d);
+
+ void process(const QList<ImageInfo>& infos);
+ void process(const ImageInfo& info);
+
+ FacePipelineExtendedPackage::Ptr filter(const ImageInfo& info);
+
+public:
+
+ FacePipeline::Private* const d;
+ FacePipeline::FilterMode mode;
+ FacePipelineFaceTagsIface::Roles tasks;
+
+protected Q_SLOTS:
+
+ void dispatch();
+
+Q_SIGNALS:
+
+ void infosToDispatch();
+
+protected:
+
+ virtual void run();
+
+protected:
+
+ QList<ImageInfo> toFilter;
+ QList<FacePipelineExtendedPackage::Ptr> toSend;
+ QList<ImageInfo> toBeSkipped;
+};
+
+} // namespace Digikam
+
+#endif // DIGIKAM_SCAN_STATE_FILTER_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic