digiKam
Loading...
Searching...
No Matches
Digikam::FaceUtils Class Reference

#include <faceutils.h>

+ 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)
 
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
 
Identity identityForUuid (const QString &uuid, const 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
 
bool normalTagChanged () 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)
 
bool rotateFaces (qlonglong imageId, const QSize &size, int oldOrientation, int newOrientation)
 
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=default
 

Static Public Member Functions

static FaceTagsIface confirmedEntry (const FaceTagsIface &face, int tagId=-1, const TagRegion &confirmedRegion=TagRegion())
 
static QRect faceRectToDisplayRect (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 > &tagIds) override
 

Member Enumeration Documentation

◆ FaceRecognitionSteps

Enumerator
DetectFaceRegions 
DetectAndRecognize 

Constructor & Destructor Documentation

◆ FaceUtils()

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

◆ ~FaceUtils()

Digikam::FaceUtils::~FaceUtils ( )
overridedefault

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

Reimplemented from parent class.

Reimplemented from Digikam::FaceTagsEditor.

References Digikam::FaceTagsEditor::addNormalTag().

◆ changeRegion()

◆ changeSuggestedName()

◆ changeTag()

FaceTagsIface Digikam::FaceTagsEditor::changeTag ( const FaceTagsIface face,
int  newTagId 
)
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 or unknown face don't remove a possible tag. See bug 449142.

We store metadata of FaceTags, if it's a confirmed person.

References Digikam::FaceTagsEditor::addFaceAndTag(), Digikam::FaceTagsIface::attributesForFlags(), Digikam::FaceTagsIface::ConfirmedName, 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(), and Digikam::FaceTagsIface::typeForId().

Referenced by Digikam::DatabaseWriter::process(), and Digikam::DisjointMetadata::write().

◆ 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()

◆ faceRectToDisplayRect()

QRect Digikam::FaceUtils::faceRectToDisplayRect ( 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(), and Digikam::FaceTags::faceNameForTag().

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(), and Digikam::TagRegion::toRect().

◆ 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(), markAsScanned(), and markAsScanned().

◆ hasBeenScanned() [2/2]

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

References hasBeenScanned().

◆ identityForTag()

◆ identityForUuid()

Identity Digikam::FaceUtils::identityForUuid ( const QString &  uuid,
const 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

◆ normalTagChanged()

bool Digikam::FaceUtils::normalTagChanged ( ) const

◆ numberOfFaces()

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

Returns the number of faces present in an image.

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

◆ removeAllFaces()

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

◆ removeFace() [1/2]

◆ removeFace() [2/2]

void Digikam::FaceTagsEditor::removeFace ( qlonglong  imageid,
const QRect &  rect 
)
inherited

◆ removeFaceAndTag()

◆ removeFaces()

void Digikam::FaceTagsEditor::removeFaces ( const QList< FaceTagsIface > &  faces)
inherited

◆ removeNormalTag()

void Digikam::FaceUtils::removeNormalTag ( qlonglong  imageId,
int  tagId 
)
overrideprotectedvirtual

◆ removeNormalTags()

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

◆ rotateFaces()

bool Digikam::FaceTagsEditor::rotateFaces ( qlonglong  imageId,
const QSize &  size,
int  oldOrientation,
int  newOrientation 
)
inherited

◆ 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.

Images in faces and thumbnails.

References Digikam::DImg::copyQImage(), Digikam::FaceTagsEditor::databaseFaces(), faceRectToDisplayRect(), Digikam::TagRegion::mapFromOriginalSize(), and Digikam::ThumbnailLoadThread::storeDetailThumbnail().

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::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: