digiKam
Digikam::FaceUtils Class Reference
+ Inheritance diagram for Digikam::FaceUtils:

Public Types

enum  FaceRecognitionSteps { DetectFaceRegions , DetectAndRecognize }
 

Public Member Functions

void add (const FaceTagsIface &face, bool trainFace=true)
 
FaceTagsIface add (qlonglong imageid, int tagId, const TagRegion &region, bool trainFace=true)
 
FaceTagsIface addManually (const FaceTagsIface &face)
 
FaceTagsIface changeRegion (const FaceTagsIface &face, const TagRegion &newRegion)
 
FaceTagsIface changeSuggestedName (const FaceTagsIface &previousEntry, int unconfirmedNameTagId)
 
FaceTagsIface changeTag (const FaceTagsIface &face, int newTagId, ItemInfo &info)
 
QList< FaceTagsIfaceconfirmedFaceTagsIfaces (qlonglong imageid) const
 
FaceTagsIface confirmName (const FaceTagsIface &face, int tagId=-1, const TagRegion &confirmedRegion=TagRegion())
 
QList< FaceTagsIfacedatabaseFaces (qlonglong imageid) const
 
QList< FaceTagsIfacedatabaseFaces (qlonglong imageId, FaceTagsIface::TypeFlags flags) const
 
QList< FaceTagsIfacedatabaseFacesForTraining (qlonglong imageid) const
 
int faceCountForPersonInImage (qlonglong imageid, int tagId) const
 
QList< ItemTagPairfaceItemTagPairs (qlonglong imageid, FaceTagsIface::TypeFlags flags) const
 
 FaceUtils (QObject *const parent=nullptr)
 
QMap< QString, QString > getSuggestedNames (qlonglong id) const
 
QList< QRect > getTagRects (qlonglong imageid) const
 
bool hasBeenScanned (const ItemInfo &info) const
 
bool hasBeenScanned (qlonglong imageid) const
 
Identity identityForTag (int tagId, FacialRecognitionWrapper &recognizer) const
 
QList< FaceTagsIfaceignoredFaceTagsIfaces (qlonglong imageid) const
 
void markAsScanned (const ItemInfo &info, bool hasBeenScanned=true) const
 
void markAsScanned (qlonglong imageid, bool hasBeenScanned=true) const
 
int numberOfFaces (qlonglong imageid) const
 
void removeAllFaces (qlonglong imageid)
 
void removeFace (const FaceTagsIface &face, bool touchTags=true)
 
void removeFace (qlonglong imageid, const QRect &rect)
 
void removeFaces (const QList< FaceTagsIface > &faces)
 
QSize rotateFaces (const ItemInfo &info, int newOrientation, int oldOrientation)
 
void storeThumbnails (ThumbnailLoadThread *const thread, const QString &filePath, const QList< FaceTagsIface > &databaseFaces, const DImg &image)
 
int tagForIdentity (const Identity &identity) const
 
QList< FaceTagsIfacetoFaceTagsIfaces (qlonglong imageid, const QList< QRectF > &detectedFaces, const QList< Identity > &recognitionResults, const QSize &fullSize) const
 
QList< FaceTagsIfaceunconfirmedFaceTagsIfaces (qlonglong imageid) const
 
QList< FaceTagsIfaceunconfirmedNameFaceTagsIfaces (qlonglong imageid) const
 
QList< FaceTagsIfacewriteUnconfirmedResults (qlonglong imageid, const QList< QRectF > &detectedFaces, const QList< Identity > &recognitionResults, const QSize &fullSize)
 
 ~FaceUtils () override
 

Static Public Member Functions

static FaceTagsIface confirmedEntry (const FaceTagsIface &face, int tagId=-1, const TagRegion &confirmedRegion=TagRegion())
 
static int faceRectDisplayMargin (const QRect &rect)
 
static FaceTagsIface unconfirmedEntry (qlonglong imageId, int tagId, const TagRegion &region)
 
static FaceTagsIface unknownPersonEntry (qlonglong imageId, const TagRegion &region)
 

Protected Member Functions

void addFaceAndTag (ItemTagPair &pair, const FaceTagsIface &face, const QStringList &properties, bool addTag)
 
void addNormalTag (qlonglong imageid, int tagId) override
 
void removeFaceAndTag (ItemTagPair &pair, const FaceTagsIface &face, bool touchTags)
 
void removeNormalTag (qlonglong imageid, int tagId) override
 
void removeNormalTags (qlonglong imageid, const QList< int > &tagId) override
 

Member Enumeration Documentation

◆ FaceRecognitionSteps

Enumerator
DetectFaceRegions 
DetectAndRecognize 

Constructor & Destructor Documentation

◆ FaceUtils()

Digikam::FaceUtils::FaceUtils ( QObject *const  parent = nullptr)
explicit

◆ ~FaceUtils()

Digikam::FaceUtils::~FaceUtils ( )
override

Member Function Documentation

◆ add() [1/2]

void Digikam::FaceTagsEditor::add ( const FaceTagsIface face,
bool  trainFace = true 
)
inherited

Adds a new entry to the database. The convenience wrapper will return the newly created entry. If trainFace is true, the face will also be listed in the db as needing training. The tag of the face will, if necessary, be converted to a person tag.

References Digikam::FaceTagsEditor::addFaceAndTag(), Digikam::FaceTagsIface::attributesForFlags(), Digikam::FaceTagsIface::ConfirmedName, Digikam::FaceTagsIface::FaceForTraining, Digikam::FaceTagsIface::imageId(), and Digikam::FaceTagsIface::tagId().

Referenced by Digikam::FaceTagsEditor::add(), Digikam::ItemScanner::commitFaces(), and Digikam::AlbumManager::mergeTAlbum().

◆ add() [2/2]

FaceTagsIface Digikam::FaceTagsEditor::add ( qlonglong  imageid,
int  tagId,
const TagRegion region,
bool  trainFace = true 
)
inherited

◆ addFaceAndTag()

◆ addManually()

◆ addNormalTag()

void Digikam::FaceUtils::addNormalTag ( qlonglong  imageid,
int  tagId 
)
overrideprotectedvirtual

Implementation for automatic assigning of face as Tag Icon, if no icon exists currently. Utilising a QTimer to ensure that a new TAlbum is given time to be created, before assigning Icon.

Reimplemented from Digikam::FaceTagsEditor.

References Digikam::FileActionMngr::assignTag(), Digikam::AlbumManager::findTAlbum(), Digikam::TAlbum::iconId(), Digikam::AlbumManager::instance(), Digikam::FileActionMngr::instance(), Digikam::FaceTags::isTheIgnoredPerson(), Digikam::FaceTags::isTheUnconfirmedPerson(), and Digikam::FaceTags::isTheUnknownPerson().

◆ changeRegion()

◆ changeSuggestedName()

◆ changeTag()

FaceTagsIface Digikam::FaceTagsEditor::changeTag ( const FaceTagsIface face,
int  newTagId,
ItemInfo info 
)
inherited

Changes the tag of the given entry. Returns the face with the new Tag.

Since a new Tag is going to be assigned to the Face, it's important to remove the association between the face and the old tagId.

If the face is being ignored and it was an unconfirmed face, don't remove a possible tag. See bug 449142

NOTE: Ignored Tag is being associated with the Images. This is to allow storing Ignored information in the metadata of the image. We store metadata of FaceTags, if it's a confirmed or ignored person.

References Digikam::FaceTagsEditor::addFaceAndTag(), Digikam::FaceTagsIface::attributesForFlags(), Digikam::FaceTagsIface::imageId(), Digikam::FaceTagsIface::isNull(), Digikam::FaceTags::isPerson(), Digikam::FaceTags::isTheIgnoredPerson(), Digikam::FaceTags::isTheUnconfirmedPerson(), Digikam::FaceTags::isTheUnknownPerson(), Digikam::FaceTagsEditor::removeFace(), Digikam::FaceTagsIface::setTagId(), Digikam::FaceTagsIface::setType(), Digikam::FaceTagsIface::tagId(), Digikam::FaceTagsIface::type(), Digikam::FaceTagsIface::typeForId(), and Digikam::FaceTagsIface::UnconfirmedName.

Referenced by Digikam::DatabaseWriter::process().

◆ confirmedEntry()

FaceTagsIface Digikam::FaceTagsEditor::confirmedEntry ( const FaceTagsIface face,
int  tagId = -1,
const TagRegion confirmedRegion = TagRegion() 
)
staticinherited

◆ confirmedFaceTagsIfaces()

QList< FaceTagsIface > Digikam::FaceTagsEditor::confirmedFaceTagsIfaces ( qlonglong  imageid) const
inherited

◆ confirmName()

FaceTagsIface Digikam::FaceTagsEditor::confirmName ( const FaceTagsIface face,
int  tagId = -1,
const TagRegion confirmedRegion = TagRegion() 
)
inherited

Assign the name tag for given face entry. Pass the tagId if it changed or was newly assigned (UnknownName). Pass the new, corrected region if it changed. If the default values are passed, tag id or region are taken from the given face. The given face should be an unchanged entry read from the database. The confirmed tag will, if necessary, be converted to a person tag. Returns the newly inserted entry.

References Digikam::FaceTagsEditor::addFaceAndTag(), Digikam::FaceTagsIface::attributesForFlags(), Digikam::FaceTagsEditor::confirmedEntry(), Digikam::FaceTagsIface::ConfirmedName, Digikam::FaceTagsIface::FaceForTraining, Digikam::FaceTagsIface::imageId(), Digikam::FaceTags::isTheIgnoredPerson(), Digikam::FaceTags::isTheUnconfirmedPerson(), Digikam::FaceTags::isTheUnknownPerson(), Digikam::FaceTagsEditor::removeFaceAndTag(), and Digikam::FaceTagsIface::tagId().

Referenced by Digikam::DatabaseWriter::process().

◆ databaseFaces() [1/2]

◆ databaseFaces() [2/2]

QList< FaceTagsIface > Digikam::FaceTagsEditor::databaseFaces ( qlonglong  imageId,
FaceTagsIface::TypeFlags  flags 
) const
inherited

◆ databaseFacesForTraining()

QList< FaceTagsIface > Digikam::FaceTagsEditor::databaseFacesForTraining ( qlonglong  imageid) const
inherited

◆ faceCountForPersonInImage()

int Digikam::FaceTagsEditor::faceCountForPersonInImage ( qlonglong  imageid,
int  tagId 
) const
inherited

Returns the number of faces a particular person has in the specified image

References Digikam::ImageTagPropertyName::tagRegion(), and Digikam::ItemTagPair::values().

◆ faceItemTagPairs()

◆ faceRectDisplayMargin()

int Digikam::FaceUtils::faceRectDisplayMargin ( const QRect &  rect)
static

For display, it may be desirable to display a slightly larger region than the strict face rectangle. This returns a pixel margin commonly used to increase the rectangle size in all four directions.

Referenced by Digikam::ItemFaceDelegate::largerFaceRect(), Digikam::DatabaseTask::run(), and storeThumbnails().

◆ getSuggestedNames()

QMap< QString, QString > Digikam::FaceTagsEditor::getSuggestedNames ( qlonglong  id) const
inherited

Returns a Map of Tag Regions (in XML format) to Suggested Name (from Face Recognition) for the given image. This function makes read operations to the database, and hence can be inefficient when called repeatedly. A cached version is provided in ItemInfo, and should be preferred for intensive operations such as sorting, categorizing etc.

For Unconfirmed Results, the value is stored as a tuple of (SuggestedId, Property, Region). Look at the digikam.db file for more details.

References Digikam::ImageTagPropertyName::autodetectedPerson(), Digikam::ItemTagPair::availablePairs(), Digikam::FaceTags::faceNameForTag(), and Digikam::ItemTagPair::values().

Referenced by Digikam::ItemInfo::getSuggestedNames().

◆ getTagRects()

QList< QRect > Digikam::FaceTagsEditor::getTagRects ( qlonglong  imageid) const
inherited

Returns a list of all tag rectangles for the image. Unlike findAndTagFaces, this does not take a DImg, because it returns only a QRect, not a Face, so no need of cropping a face rectangle.

References Digikam::ItemTagPair::availablePairs(), Digikam::ImageTagPropertyName::tagRegion(), Digikam::TagRegion::toRect(), and Digikam::ItemTagPair::values().

◆ hasBeenScanned() [1/2]

bool Digikam::FaceUtils::hasBeenScanned ( const ItemInfo info) const

Tells if the image has been scanned for faces or not

References Digikam::FaceTags::scannedForFacesTagId(), and Digikam::ItemInfo::tagIds().

Referenced by Digikam::ScanStateFilter::filter(), hasBeenScanned(), and markAsScanned().

◆ hasBeenScanned() [2/2]

bool Digikam::FaceUtils::hasBeenScanned ( qlonglong  imageid) const

References hasBeenScanned().

◆ identityForTag()

Identity Digikam::FaceUtils::identityForTag ( int  tagId,
FacialRecognitionWrapper recognizer 
) const

◆ ignoredFaceTagsIfaces()

QList< FaceTagsIface > Digikam::FaceTagsEditor::ignoredFaceTagsIfaces ( qlonglong  imageid) const
inherited

◆ markAsScanned() [1/2]

void Digikam::FaceUtils::markAsScanned ( const ItemInfo info,
bool  hasBeenScanned = true 
) const

◆ markAsScanned() [2/2]

void Digikam::FaceUtils::markAsScanned ( qlonglong  imageid,
bool  hasBeenScanned = true 
) const

Marks the image as scanned for faces.

References hasBeenScanned().

Referenced by Digikam::DatabaseWriter::process().

◆ numberOfFaces()

int Digikam::FaceTagsEditor::numberOfFaces ( qlonglong  imageid) const
inherited

◆ removeAllFaces()

void Digikam::FaceTagsEditor::removeAllFaces ( qlonglong  imageid)
inherited

◆ removeFace() [1/2]

◆ removeFace() [2/2]

◆ removeFaceAndTag()

◆ removeFaces()

◆ removeNormalTag()

◆ removeNormalTags()

void Digikam::FaceUtils::removeNormalTags ( qlonglong  imageid,
const QList< int > &  tagId 
)
overrideprotectedvirtual

◆ rotateFaces()

◆ storeThumbnails()

void Digikam::FaceUtils::storeThumbnails ( ThumbnailLoadThread *const  thread,
const QString &  filePath,
const QList< FaceTagsIface > &  databaseFaces,
const DImg image 
)

This uses a thumbnail load thread to load the image detail. If requested, the faces will be scaled to the given (fixed) size. Store the needed thumbnails for the given faces. This can be a huge optimization when the has already been loaded anyway.

References Digikam::DImg::copyQImage(), Digikam::FaceTagsEditor::databaseFaces(), faceRectDisplayMargin(), Digikam::TagRegion::mapFromOriginalSize(), Digikam::FaceTagsIface::region(), Digikam::ThumbnailLoadThread::storeDetailThumbnail(), and Digikam::TagRegion::toRect().

Referenced by Digikam::DatabaseWriter::process().

◆ tagForIdentity()

int Digikam::FaceUtils::tagForIdentity ( const Identity identity) const

◆ toFaceTagsIfaces()

QList< FaceTagsIface > Digikam::FaceUtils::toFaceTagsIfaces ( qlonglong  imageid,
const QList< QRectF > &  detectedFaces,
const QList< Identity > &  recognitionResults,
const QSize &  fullSize 
) const

◆ unconfirmedEntry()

FaceTagsIface Digikam::FaceTagsEditor::unconfirmedEntry ( qlonglong  imageId,
int  tagId,
const TagRegion region 
)
staticinherited

Returns the entry that would be added if the given face is autodetected. If tagId is -1, the unknown person will be taken.

References Digikam::FaceTagsIface::UnconfirmedName, and Digikam::FaceTags::unknownPersonTagId().

Referenced by Digikam::FacePipeline::addManually(), Digikam::FaceTagsEditor::changeSuggestedName(), Digikam::DatabaseWriter::process(), and Digikam::FaceTagsEditor::unknownPersonEntry().

◆ unconfirmedFaceTagsIfaces()

QList< FaceTagsIface > Digikam::FaceTagsEditor::unconfirmedFaceTagsIfaces ( qlonglong  imageid) const
inherited

Returns list of Unconfirmed and Unknown faces in the Image. If you want just Unconfirmed Faces,

See also
unconfirmedNameFaceTagsIfaces

References Digikam::FaceTagsEditor::databaseFaces(), and Digikam::FaceTagsIface::UnconfirmedTypes.

Referenced by Digikam::ScanStateFilter::filter(), and Digikam::DatabaseWriter::process().

◆ unconfirmedNameFaceTagsIfaces()

QList< FaceTagsIface > Digikam::FaceTagsEditor::unconfirmedNameFaceTagsIfaces ( qlonglong  imageid) const
inherited

Returns a list of UnconfirmedFaces in the Image. Different from

See also
unconfirmedFaceTagsIfaces

References Digikam::FaceTagsEditor::databaseFaces(), and Digikam::FaceTagsIface::UnconfirmedName.

Referenced by Digikam::ItemInfo::unconfirmedFaceCount().

◆ unknownPersonEntry()

FaceTagsIface Digikam::FaceTagsEditor::unknownPersonEntry ( qlonglong  imageId,
const TagRegion region 
)
staticinherited

◆ writeUnconfirmedResults()

QList< FaceTagsIface > Digikam::FaceUtils::writeUnconfirmedResults ( qlonglong  imageid,
const QList< QRectF > &  detectedFaces,
const QList< Identity > &  recognitionResults,
const QSize &  fullSize 
)

The documentation for this class was generated from the following files: