File indexing completed on 2025-01-19 03:57:56

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-09-03
0007  * Description : Integrated, multithread face detection / recognition
0008  *
0009  * SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "facepipeline_p.h"
0017 
0018 // Local includes
0019 
0020 #include "databasewriter.h"
0021 #include "detectionbenchmarker.h"
0022 #include "detectionworker.h"
0023 #include "recognitionbenchmarker.h"
0024 #include "recognitionworker.h"
0025 #include "trainerworker.h"
0026 #include "facepreviewloader.h"
0027 #include "faceitemretriever.h"
0028 #include "parallelpipes.h"
0029 #include "scanstatefilter.h"
0030 
0031 namespace Digikam
0032 {
0033 
0034 FacePipelineFaceTagsIface::FacePipelineFaceTagsIface()
0035     : roles         (NoRole),
0036       assignedTagId (0)
0037 {
0038 }
0039 
0040 FacePipelineFaceTagsIface::FacePipelineFaceTagsIface(const FaceTagsIface& face)
0041     : FaceTagsIface (face),
0042       roles         (NoRole),
0043       assignedTagId (0)
0044 {
0045 }
0046 
0047 FacePipelineFaceTagsIface::~FacePipelineFaceTagsIface()
0048 {
0049 }
0050 
0051 // ----------------------------------------------------------------------------------------
0052 
0053 FacePipelineFaceTagsIfaceList::FacePipelineFaceTagsIfaceList()
0054 {
0055 }
0056 
0057 FacePipelineFaceTagsIfaceList::~FacePipelineFaceTagsIfaceList()
0058 {
0059 }
0060 
0061 FacePipelineFaceTagsIfaceList::FacePipelineFaceTagsIfaceList(const QList<FaceTagsIface>& faces)
0062 {
0063     operator=(faces);
0064 }
0065 
0066 FacePipelineFaceTagsIfaceList& FacePipelineFaceTagsIfaceList::operator=(const QList<FaceTagsIface>& faces)
0067 {
0068     Q_FOREACH (const FaceTagsIface& face, faces)
0069     {
0070         operator<<(FacePipelineFaceTagsIface(face));
0071     }
0072 
0073     return *this;
0074 }
0075 
0076 void FacePipelineFaceTagsIfaceList::setRole(FacePipelineFaceTagsIface::Roles role)
0077 {
0078     for (iterator it = begin() ; it != end() ; ++it)
0079     {
0080         it->roles |= role;
0081     }
0082 }
0083 
0084 void FacePipelineFaceTagsIfaceList::clearRole(FacePipelineFaceTagsIface::Roles role)
0085 {
0086     for (iterator it = begin() ; it != end() ; ++it)
0087     {
0088         it->roles &= ~role;
0089     }
0090 }
0091 
0092 void FacePipelineFaceTagsIfaceList::replaceRole(FacePipelineFaceTagsIface::Roles remove,
0093                                                 FacePipelineFaceTagsIface::Roles add)
0094 {
0095     for (iterator it = begin() ; it != end() ; ++it)
0096     {
0097         if (it->roles & remove)
0098         {
0099             it->roles &= ~remove;
0100             it->roles |= add;
0101         }
0102     }
0103 }
0104 
0105 QList<FaceTagsIface> FacePipelineFaceTagsIfaceList::toFaceTagsIfaceList() const
0106 {
0107     QList<FaceTagsIface> faces;
0108 
0109     for (const_iterator it = constBegin() ; it != constEnd() ; ++it)
0110     {
0111         faces << *it;
0112     }
0113 
0114     return faces;
0115 }
0116 
0117 FacePipelineFaceTagsIfaceList FacePipelineFaceTagsIfaceList::facesForRole(FacePipelineFaceTagsIface::Roles role) const
0118 {
0119     FacePipelineFaceTagsIfaceList faces;
0120 
0121     for (const_iterator it = constBegin() ; it != constEnd() ; ++it)
0122     {
0123         if (it->roles & role)
0124         {
0125             faces << *it;
0126         }
0127     }
0128 
0129     return faces;
0130 }
0131 
0132 // -----------------------------------------------------------------------------------------
0133 
0134 FacePipelinePackage::FacePipelinePackage()
0135     : processFlags(NotProcessed)
0136 {
0137 }
0138 
0139 FacePipelinePackage::~FacePipelinePackage()
0140 {
0141 }
0142 
0143 // ----------------------------------------------------------------------------------------
0144 
0145 FacePipelineExtendedPackage::FacePipelineExtendedPackage()
0146 {
0147 }
0148 
0149 FacePipelineExtendedPackage::~FacePipelineExtendedPackage()
0150 {
0151 }
0152 
0153 // ----------------------------------------------------------------------------------------
0154 
0155 FacePipelineExtendedPackage::Ptr PackageLoadingDescriptionList::take(const LoadingDescription& description)
0156 {
0157     FacePipelineExtendedPackage::Ptr                  package;
0158     QList<FacePipelineExtendedPackage::Ptr>::iterator it;
0159 
0160     for (it = begin() ; it != end() ; ++it)
0161     {
0162         if (*(*it) == description)
0163         {
0164             package = *it;
0165             erase(it);
0166             break;
0167         }
0168     }
0169 
0170     return package;
0171 }
0172 
0173 bool FacePipelineExtendedPackage::operator==(const LoadingDescription& description) const
0174 {
0175     return (filePath == description.filePath);
0176 }
0177 
0178 // ----------------------------------------------------------------------------------------
0179 
0180 PackageLoadingDescriptionList::PackageLoadingDescriptionList()
0181 {
0182 }
0183 
0184 PackageLoadingDescriptionList::~PackageLoadingDescriptionList()
0185 {
0186 }
0187 
0188 } // namespace Digikam