1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
/* ============================================================
 *
 * This file is a part of digiKam project
 * https://www.digikam.org
 *
 * Date        : 2024-11-10
 * Description : Performs face detection and recognition
 *
 * SPDX-FileCopyrightText: 2024-2025 by Gilles Caulier <caulier dot gilles at gmail dot com>
 * SPDX-FileCopyrightText: 2024-2025 by Michael Miller <michael underscore miller at msn dot com>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * ============================================================ */

#include "facepipelinedetectrecognize.h"

// Qt includes

#include <QList>
#include <QSet>
#include <QElapsedTimer>
#include <QRectF>

// KDE includes

#include <klocalizedstring.h>

// Local includes

#include "digikam_debug.h"
#include "digikam_opencv.h"
#include "sharedqueue.h"
#include "collectionmanager.h"
#include "album.h"
#include "iteminfo.h"
#include "coredb.h"
#include "facescansettings.h"
#include "dimg.h"
#include "previewloadthread.h"
#include "faceutils.h"
#include "facepipelinepackagebase.h"
#include "thumbnailloadthread.h"
#include "faceclassifier.h"
#include "identityprovider.h"
#include "qtopencvimg.h"

namespace Digikam
{

FacePipelineDetectRecognize::FacePipelineDetectRecognize(const FaceScanSettings& _settings)
    : FacePipelineBase(_settings)
{
}

FacePipelineDetectRecognize::~FacePipelineDetectRecognize()
{
    if (faceDetector)
    {
        delete faceDetector;
    }

    // extractor is singleton, so no need to delete it
}

bool FacePipelineDetectRecognize::start()
{

    // create the face detector and extractor

    try
    {
        faceDetector  = new DNNFaceDetectorYuNet;
        faceExtractor = static_cast<DNNModelSFace*>(DNNModelManager::instance()->getModel(QStringLiteral("sface"),
                                                                                          DNNModelUsage::DNNUsageFaceRecognition));
        faceExtractor->getNet();
    }

    catch (const std::exception& e)
    {
        std::cerr << e.what() << '\n';

        if (faceDetector)
        {
            delete faceDetector;
            faceDetector = nullptr;
        }

        // extractor is singleton, so no need to delete it
    }

    catch (...)
    {
        if (faceDetector)
        {
            delete faceDetector;
            faceDetector = nullptr;
        }
    }

    // check if the detector and extractor were created

    if ((nullptr == faceDetector) || (nullptr == faceExtractor) || !faceExtractor->modelLoaded)
    {
        return false;
    }

    // set the face detection size and accuracy

    faceDetector->setFaceDetectionSize(settings.detectSize);
    faceDetector->uiConfidenceThreshold = settings.detectAccuracy;

    {
        // use the mutex to synchronize the start of the threads

        QMutexLocker lock(&mutex);

        // add the worker threads for this pipeline

        addWorker(MLPipelineStage::Finder);
        addWorker(MLPipelineStage::Loader);
        addWorker(MLPipelineStage::Extractor);
        addWorker(MLPipelineStage::Classifier);
        addWorker(MLPipelineStage::Writer);
    }

    return FacePipelineBase::start();
}

bool FacePipelineDetectRecognize::finder()
{
    MLPIPELINE_FINDER_START(MLPipelineStage::Loader);

    /* =========================================================================================
     * Pipeline finder specific initialization code
     *
     * Use the block from here to MLPIPELINE_FINDER_END to find the IDs images to process.
     * The code in this block is run once per stage initialization. The number of instances
     * is always 1.
     */

    // get the IDs to process

    QSet<qlonglong> filter;
    int serialNumber = 0;

    for (const Album* const album : std::as_const(settings.albums))
    {
        if (cancelled)
        {
            break;
        }

        if (!album->isTrashAlbum())
        {
            // get the image IDs for the album

            QList<qlonglong> imageIds = CoreDbAccess().db()->getImageIds(album->id(),
                                                                         DatabaseItem::Status::Visible,
                                                                         (FaceScanSettings::AlreadyScannedHandling::Skip != settings.alreadyScannedHandling));

            // quick check if we should add threads.

            if (!moreCpu)
            {
                moreCpu = checkMoreWorkers(totalItemCount, imageIds.size(), settings.useFullCpu);
            }

            // iterate over the image IDs and add unique IDs to the queue for processing

            for (qlonglong imageId : std::as_const(imageIds))
            {
                // filter out duplicate image IDs

                if (!filter.contains(imageId))
                {
                    ++totalItemCount;
                    filter << imageId;
                    enqueue(nextQueue, new FacePipelinePackageBase(imageId, ++serialNumber));
                }
            }
        }
    }

    for (const ItemInfo& info : std::as_const(settings.infos))
    {
        // filter out duplicate image IDs

        qlonglong imageId = info.id();

        if (!filter.contains(imageId))
        {
            ++totalItemCount;
            filter << imageId;
            enqueue(nextQueue, new FacePipelinePackageBase(imageId, ++serialNumber));
        }
    }

    /* =========================================================================================
     * Pipeline finder specific cleanup
     *
     * Use the block from here to MLPIPELINE_FINDER_END to clean up any resources used by the stage.
     */

    MLPIPELINE_FINDER_END(MLPipelineStage::Loader);
}

bool FacePipelineDetectRecognize::loader()
{
    MLPIPELINE_STAGE_START(QThread::LowPriority, MLPipelineStage::Loader, MLPipelineStage::Extractor);
    FacePipelinePackageBase* package = nullptr;

    /* =========================================================================================
     * Pipeline stage specific initialization code
     *
     * Use the block from here to MLPIPELINE_LOOP_START to initialize the stage.
     * The code in this block is run once per stage initialization. The number of instances
     * is at least 1. More instances are created by addMoreWorkers if needed.
     */

    MLPIPELINE_LOOP_START(MLPipelineStage::Loader, thisQueue);
    package = static_cast<FacePipelinePackageBase*>(mlpackage);

    /* =========================================================================================
     * Start pipeline stage specific loop
     *
     * All code from here to MLPIPELINE_LOOP_END is in a try/catch block and loop.
     * This loop is run once per image.
     */
    {
        // check if the ID is for an image (not video or other file type)

        bool sendNotification = true;

        if (DatabaseItem::Category::Image == package->info.category())
        {
            // load high quality image for detection

            package->image = PreviewLoadThread::loadHighQualitySynchronously(package->info.filePath());

            // check for corrupted images that can't be loaded

            if (!package->image.isNull())
            {
                // create a thumbnail for the notification

                package->thumbnailIcon = QIcon(package->image.smoothScale(48, 48, Qt::KeepAspectRatio).convertToPixmap());

                // send to the next stage

                enqueue(nextQueue, package);

                package = nullptr;

                sendNotification = false;
            }
        }

        if (sendNotification)
        {
            // send a notification that the file was skipped

            notify(MLPipelineNotification::notifySkipped,
                   package->info.name(),
                   package->info.relativePath(),
                   QString(),
                   0,
                   package->thumbnailIcon);

            // delete the package since it is not needed

            delete package;

            package = nullptr;
        }
    }

    /* =========================================================================================
     * End pipeline stage specific loop
     */

    MLPIPELINE_LOOP_END(MLPipelineStage::Loader, "FacePipelineDetectRecognize::loader");

    /* =========================================================================================
     * Pipeline stage specific cleanup
     *
     * Use the block from here to MLPIPELINE_STAGE_END to clean up any resources used by the stage.
     */

    MLPIPELINE_STAGE_END(MLPipelineStage::Loader, MLPipelineStage::Extractor);
}

bool FacePipelineDetectRecognize::extractor()
{
    MLPIPELINE_STAGE_START(QThread::NormalPriority, MLPipelineStage::Extractor, MLPipelineStage::Classifier);
    FacePipelinePackageBase* package = nullptr;

    /* =========================================================================================
     * Pipeline stage specific initialization code
     *
     * Use the block from here to MLPIPELINE_LOOP_START to initialize the stage.
     * The code in this block is run once per stage initialization. The number of instances
     * is at least 1. More instances are created by addMoreWorkers if needed.
     */

    FaceUtils utils;

    MLPIPELINE_LOOP_START(MLPipelineStage::Extractor, thisQueue);
    package = static_cast<FacePipelinePackageBase*>(mlpackage);

    /* =========================================================================================
     * Start pipeline stage specific loop
     *
     * All code from here to MLPIPELINE_LOOP_END is in a try/catch block and loop.
     * This loop is run once per image.
     */

    {
        // preprocess the image

        // copy the image to a cv::UMat

        cv::UMat cvUResizedImage;
        cv::UMat cvUImage   = QtOpenCVImg::image2Mat(
                                                     package->image,
                                                     CV_8UC3,
                                                     QtOpenCVImg::MatColorOrder::MCO_RGB
                                                    )
                                                    .getUMat(cv::ACCESS_RW);

        // resize the image if needed. Only resize if the image is larger than the input size of the detector

        cv::Size inputImageSize = faceDetector->nnInputSizeRequired();
        float resizeFactor      = 1.0F;<--- Shadowed declaration
        
        if (std::max(cvUImage.cols, cvUImage.rows) > std::max(inputImageSize.width, inputImageSize.height))
        {
            // Image should be resized. YuNet image sizes are much more flexible than SSD and YOLO
            // so we just need to make sure no one bound exceeds the max. No padding needed.

            resizeFactor            = std::min(static_cast<float>(inputImageSize.width)  / static_cast<float>(cvUImage.cols),
                                               static_cast<float>(inputImageSize.height) / static_cast<float>(cvUImage.rows));

            int newWidth            = (int)(resizeFactor * cvUImage.cols);
            int newHeight           = (int)(resizeFactor * cvUImage.rows);
            cv::resize(cvUImage, cvUResizedImage, cv::Size(newWidth, newHeight));
        }

        // get reciprocal factor for resizing the face to back the original image size

        float reciprocalFactor = 1.0F / resizeFactor;

        // detect any faces in the image

        cv::UMat udetectionResults  = faceDetector->callModel(cvUResizedImage);

        // process detected faces

        if (udetectionResults.rows > 0)
        {
            cv::Mat detectionResults   = udetectionResults.getMat(cv::ACCESS_READ);

            // get list of previously confirmed faces

            QList<FaceTagsIface> faces = utils.confirmedFaceTagsIfaces(package->info.id());

            // get list of previously ignored faces

            faces                     += utils.ignoredFaceTagsIfaces(package->info.id());

            QList<QRectF> faceFRects;

            // Loop through the faces found.

            for (int i = 0 ; i < detectionResults.rows ; ++i)
            {
                // Create the rect of the face.

                int X       = static_cast<int>(detectionResults.at<float>(i, 0));
                int Y       = static_cast<int>(detectionResults.at<float>(i, 1));
                int width   = static_cast<int>(detectionResults.at<float>(i, 2));
                int height  = static_cast<int>(detectionResults.at<float>(i, 3));

                // Add the rect to result list.

                faceFRects << QRectF(qreal(X)      / qreal(cvUResizedImage.cols),
                                     qreal(Y)      / qreal(cvUResizedImage.rows),
                                     qreal(width)  / qreal(cvUResizedImage.cols),
                                     qreal(height) / qreal(cvUResizedImage.rows));

                // check if rect is already assigned to a face to filter out confirmed and ignored faces

                bool found = false;

                if (faces.size() > 0)
                {
                    for (int j = 0; j < faces.size(); ++j)
                    {
                        // compute current image relative rect

                        QRect rect = QRect(package->image.width()  * faceFRects[i].x(),
                                           package->image.height() * faceFRects[i].y(),
                                           package->image.width()  * faceFRects[i].width(),
                                           package->image.height() * faceFRects[i].height());

                        if (faces[j].region().intersects(TagRegion(rect), 0.85))
                        {
                            found = true;

                            break;
                        }
                    }
                }

                // if face is not found (confirmed), then extract for classification

                if (!found)
                {
                    cv::UMat ualignedFace;
                    cv::UMat uface_features;
                    cv::Mat  face_features;

                    // extract the face vectors (features) for classification

                    {
                        // get cvMat of the face landmarks

                        cv::Mat row = udetectionResults.getMat(cv::ACCESS_READ).row(i);
                        
                        // convert the face landmarks to the full size image

                        for (int j = 0; j < row.cols; ++j)
                        {
                            row.at<float>(j) = (int)(row.at<float>(j) * reciprocalFactor);
                        }

                        // convert the face landmarks to a UMat

                        cv::UMat urow = row.getUMat(cv::ACCESS_READ);

                        // align and crop the face

                        QMutexLocker lock(&(faceExtractor->mutex));

                        faceExtractor->getNet()->alignCrop(cvUImage, urow, ualignedFace);

                        cv::UMat paddedFace;

                        if (std::min(ualignedFace.cols, ualignedFace.rows) > 112)
                        {
                            // Image should be resized. YuNet image sizes are much more flexible than SSD and YOLO.
                            // So we just need to make sure no one bound exceeds the max. No padding needed.
                    
                            float resizeFactor      = std::min(static_cast<float>(112) / static_cast<float>(ualignedFace.cols),<--- Shadow variable
                                                               static_cast<float>(112) / static_cast<float>(ualignedFace.rows));
                    
                            int newWidth            = (int)(resizeFactor * ualignedFace.cols);
                            int newHeight           = (int)(resizeFactor * ualignedFace.rows);
                            cv::resize(ualignedFace, paddedFace, cv::Size(newWidth, newHeight));
                        }
                        else
                        {
                            paddedFace = ualignedFace.clone();
                        }

                        ualignedFace.release();

                        // get the face features
            
                        faceExtractor->getNet()->feature(paddedFace, uface_features);

                        face_features = uface_features.getMat(cv::ACCESS_READ);
                    }

                    // normalize the face features if we have any

                    if (0 < face_features.rows)
                    {
                        // normalize the face features

                        cv::Mat normalized_features;
                        normalize(face_features, normalized_features);

                        // add the face features and face rect to the package

                        package->featuresList << normalized_features;
                        package->faceRects << faceFRects[i];
                    }
                }
            }
        }

        // send the package to the next stage

        enqueue(nextQueue, package);
    
        package = nullptr;
    }

    /* =========================================================================================
     * End pipeline stage specific loop
     */

    MLPIPELINE_LOOP_END(MLPipelineStage::Extractor, "FacePipelineDetectRecognize::extractor");

    /* =========================================================================================
     * Pipeline stage specific cleanup
     *
     * Use the block from here to MLPIPELINE_STAGE_END to clean up any resources used by the stage.
     */

    MLPIPELINE_STAGE_END(MLPipelineStage::Extractor, MLPipelineStage::Classifier);
}

bool FacePipelineDetectRecognize::classifier()
{
    MLPIPELINE_STAGE_START(QThread::LowPriority, MLPipelineStage::Classifier, MLPipelineStage::Writer);
    FacePipelinePackageBase* package = nullptr;

    /* =========================================================================================
     * Pipeline stage specific initialization code
     *
     * Use the block from here to MLPIPELINE_LOOP_START to initialize the stage.
     * The code in this block is run once per stage initialization. The number of instances
     * is at least 1. More instances are created by addMoreWorkers if needed.
     */

    FaceClassifier* const classifier = FaceClassifier::instance();
    classifier->setParameters(settings);

    MLPIPELINE_LOOP_START(MLPipelineStage::Classifier, thisQueue);
    package = static_cast<FacePipelinePackageBase*>(mlpackage);

    /* =========================================================================================
     * Start pipeline stage specific loop
     *
     * All code from here to MLPIPELINE_LOOP_END is in a try/catch block and loop.
     * This loop is run once per image.
     */

    {
        for (int i = 0 ; i < package->featuresList.size() ; ++i)
        {
            // verify the feature mat is not empty

            if (0 < package->featuresList[i].rows)
            {
                // classify the features

                package->labelList << classifier->predict(package->featuresList[i]);
            }
            else
            {
                package->labelList << -1;
            }
        }

        enqueue(nextQueue, package);

        package = nullptr;
    }

    /* =========================================================================================
     * End pipeline stage specific loop
     */

    MLPIPELINE_LOOP_END(MLPipelineStage::Classifier, "FacePipelineDetectRecognize::classifier");

    /* =========================================================================================
     * Pipeline stage specific cleanup
     *
     * Use the block from here to MLPIPELINE_STAGE_END to clean up any resources used by the stage.
     */

    MLPIPELINE_STAGE_END(MLPipelineStage::Classifier, MLPipelineStage::Writer);
}

bool FacePipelineDetectRecognize::writer()
{
    MLPIPELINE_STAGE_START(QThread::LowPriority, MLPipelineStage::Writer, MLPipelineStage::None);
    FacePipelinePackageBase* package = nullptr;

    /* =========================================================================================
     * Pipeline stage specific initialization code
     *
     * Use the block from here to MLPIPELINE_LOOP_START to initialize the stage.
     * The code in this block is run once per stage initialization. The number of instances
     * is at least 1. More instances are created by addMoreWorkers if needed.
     */

    IdentityProvider* const    idProvider          = IdentityProvider::instance();
    FaceUtils                  utils;
    ThumbnailLoadThread* const thumbnailLoadThread = ThumbnailLoadThread::defaultThread();
    const QList<AlbumRootInfo> roots               = CoreDbAccess().db()->getAlbumRoots();
    Q_UNUSED(roots);

    MLPIPELINE_LOOP_START(MLPipelineStage::Writer, thisQueue);
    package                                        = static_cast<FacePipelinePackageBase*>(mlpackage);

    /* =========================================================================================
     * Start pipeline stage specific loop
     *
     * All code from here to MLPIPELINE_LOOP_END is in a try/catch block and loop.
     * This loop is run once per image.
     */

    {
        switch (settings.alreadyScannedHandling)
        {
            case FaceScanSettings::Rescan:
            {
                // remove old unconfirmed face rects

                QList<FaceTagsIface> oldEntries = utils.unconfirmedFaceTagsIfaces(package->info.id());
                utils.removeFaces(oldEntries);
                break;
            }

            case FaceScanSettings::ClearAll:
            {
                // remove all face rects

                utils.removeAllFaces(package->info.id());
                break;
            }

            case FaceScanSettings::RecognizeOnly:
            case FaceScanSettings::Skip:
            {
                // do nothing
                // Skipped images were skipped in the finder stage
                // RecognizeOnly defines the pipeline

                break;
            }
        }

        // mark the image as scanned

        utils.markAsScanned(package->info);

        // create thumbnails and write the new face rects to the database

        QStringList names;

        if (package->faceRects.size())
        {
            QList<FaceTagsIface>    databaseFaces;
            QList<Identity>         identities;

            for (int i = 0 ; i < package->faceRects.size() ; ++i)
            {
                QRect faceRect(std::round(package->image.width()  * package->faceRects[i].x()),
                               std::round(package->image.height() * package->faceRects[i].y()),
                               std::round(package->image.width()  * package->faceRects[i].width()),
                               std::round(package->image.height() * package->faceRects[i].height()));

                if (package->labelList[i] != -1)
                {
                    Identity identity = idProvider->identity(package->labelList[i]);
                    names << identity.attribute(QStringLiteral("name"));
                    identities << identity;
                    databaseFaces << FaceTagsIface(FaceTagsIface::Type::UnconfirmedName,
                                                   package->info.id(),
                                                   FaceTags::unconfirmedPersonTagId(),
                                                   TagRegion(faceRect));
                }
                else
                {
                    identities << Identity();
                    databaseFaces << FaceTagsIface(FaceTagsIface::Type::UnknownName,
                                                   package->info.id(),
                                                   FaceTags::unknownPersonTagId(),
                                                   TagRegion(faceRect));
                }
            }

            // store the thumbnails

            if (!package->image.isNull())
            {
                utils.storeThumbnails(thumbnailLoadThread, package->info.filePath(),
                                      databaseFaces, package->image);
            }

            // write the new face rects to the database

            utils.writeUnconfirmedResults(package->info.id(),
                                          package->faceRects,
                                          identities,
                                          package->image.originalSize());
        }

        QString albumName = CollectionManager::instance()->albumRootLabel(package->info.albumRootId());

        // send a notification that the image was processed

        notify(MLPipelineNotification::notifyProcessed,
               package->info.name(),
               albumName + package->info.relativePath(),
               names.join(QLatin1String(", ")),
               package->faceRects.size(),
               package->thumbnailIcon);

        // delete the package

        delete package;
    
        package = nullptr;
    }

    /* =========================================================================================
     * End pipeline stage specific loop
     */

    MLPIPELINE_LOOP_END(MLPipelineStage::Writer, "FacePipelineDetectRecognize::writer");

    /* =========================================================================================
     * Pipeline stage specific cleanup
     *
     * Use the block from here to MLPIPELINE_STAGE_END to clean up any resources used by the stage.
     */

    MLPIPELINE_STAGE_END(MLPipelineStage::Writer, MLPipelineStage::None);
}

void FacePipelineDetectRecognize::addMoreWorkers()
{
    /* =========================================================================================
     * Use the performanceProfile metrics to find the slowest stages
     * and add more workers to those stages.
     *
     * For the Face detection and recognition pipeline, the loader is the
     * slowest stage so add 3 more loaders, 2 more extractors, and 1 more classifier.
     */

    addWorker(Loader);
    addWorker(Loader);
    addWorker(Loader);
    addWorker(Extractor);
    addWorker(Extractor);
    addWorker(Classifier);
}

} // namespace Digikam

#include "moc_facepipelinedetectrecognize.cpp"