digiKam
Digikam::HaarIface Class Reference

Classes

class  Private
 

Public Types

enum  AlbumTagRelation {
  NoMix = 0 , Union = 1 , Intersection = 2 , AlbumExclusive = 3 ,
  TagExclusive = 4
}
 
using DuplicatesResultsMap = QMap< qlonglong, QPair< double, QList< qlonglong > > >
 
enum  DuplicatesSearchRestrictions { None = 0 , SameAlbum = 1 , DifferentAlbum = 2 }
 
enum  SketchType { ScannedSketch = 0 , HanddrawnSketch = 1 }
 

Public Member Functions

QPair< double, QMap< qlonglong, double > > bestMatchesForImageWithThreshold (const QString &imagePath, double requiredPercentage, double maximumPercentage, const QList< int > &targetAlbums, DuplicatesSearchRestrictions searchResultRestriction=DuplicatesSearchRestrictions::None, SketchType type=ScannedSketch)
 
QPair< double, QMap< qlonglong, double > > bestMatchesForImageWithThreshold (qlonglong imageid, double requiredPercentage, double maximumPercentage, const QList< int > &targetAlbums, DuplicatesSearchRestrictions searchResultRestriction=DuplicatesSearchRestrictions::None, SketchType type=ScannedSketch)
 
QMap< qlonglong, double > bestMatchesForSignature (const QString &signature, const QList< int > &targetAlbums, int numberOfResults=20, SketchType type=ScannedSketch)
 
DuplicatesResultsMap findDuplicates (const QSet< qlonglong > &images2Scan, const QSet< qlonglong >::const_iterator &rangeBegin, const QSet< qlonglong >::const_iterator &rangeEnd, double requiredPercentage, double maximumPercentage, DuplicatesSearchRestrictions searchResultRestriction=DuplicatesSearchRestrictions::None, HaarProgressObserver *const observer=nullptr)
 
bool fulfillsRestrictions (qlonglong imageId, int albumId, qlonglong originalImageId, int originalAlbumId, const QList< int > &targetAlbums, DuplicatesSearchRestrictions searchResultRestriction)
 
void getBestAndWorstPossibleScore (Haar::SignatureData *const querySig, SketchType type, double *const lowestAndBestScore, double *const highestAndWorstScore)
 
 HaarIface ()
 
 HaarIface (const QSet< qlonglong > &images2Scan)
 
bool indexImage (const QString &filename)
 
bool indexImage (const QString &filename, const DImg &image)
 
bool indexImage (const QString &filename, const QImage &image)
 
bool indexImage (qlonglong imageid, const DImg &image)
 
bool indexImage (qlonglong imageid, const QImage &image)
 
QImage loadQImage (const QString &filename)
 
bool retrieveSignatureFromDB (qlonglong imageid, Haar::SignatureData &sig)
 
void setAlbumRootsToSearch (const QList< int > &albumRootIds)
 
void setAlbumRootsToSearch (const QSet< int > &albumRootIds)
 
QString signatureAsText (const QImage &image)
 
 ~HaarIface ()
 

Static Public Member Functions

static QSet< qlonglong > imagesFromAlbumsAndTags (const QList< int > &albums2Scan, const QList< int > &tags2Scan, AlbumTagRelation relation)
 
static int preferredSize ()
 
static void rebuildDuplicatesAlbums (const DuplicatesResultsMap &results, bool isAlbumUpdate)
 

Member Typedef Documentation

◆ DuplicatesResultsMap

using Digikam::HaarIface::DuplicatesResultsMap = QMap<qlonglong, QPair<double, QList<qlonglong> > >

Member Enumeration Documentation

◆ AlbumTagRelation

Enumerator
NoMix 
Union 
Intersection 
AlbumExclusive 
TagExclusive 

◆ DuplicatesSearchRestrictions

Enumerator
None 
SameAlbum 
DifferentAlbum 

◆ SketchType

Enumerator
ScannedSketch 
HanddrawnSketch 

Constructor & Destructor Documentation

◆ HaarIface() [1/2]

Digikam::HaarIface::HaarIface ( )
explicit

◆ HaarIface() [2/2]

Digikam::HaarIface::HaarIface ( const QSet< qlonglong > &  images2Scan)
explicit

◆ ~HaarIface()

Digikam::HaarIface::~HaarIface ( )

Member Function Documentation

◆ bestMatchesForImageWithThreshold() [1/2]

QPair< double, QMap< qlonglong, double > > Digikam::HaarIface::bestMatchesForImageWithThreshold ( const QString &  imagePath,
double  requiredPercentage,
double  maximumPercentage,
const QList< int > &  targetAlbums,
DuplicatesSearchRestrictions  searchResultRestriction = DuplicatesSearchRestrictions::None,
SketchType  type = ScannedSketch 
)

Searches the database for the best matches for the specified query image. All matches with a similarity in a given threshold interval are returned. The threshold is in the range requiredPercentage..maximumPercentage.

References Digikam::Haar::Calculator::calcHaar(), Digikam::SimilarityDbAccess::db(), Digikam::HaarIface::Private::imageData(), Digikam::DImg::isNull(), Digikam::SimilarityDb::removeImageSimilarity(), Digikam::HaarIface::Private::setImageDataFromImage(), and Digikam::Haar::Calculator::transform().

◆ bestMatchesForImageWithThreshold() [2/2]

QPair< double, QMap< qlonglong, double > > Digikam::HaarIface::bestMatchesForImageWithThreshold ( qlonglong  imageid,
double  requiredPercentage,
double  maximumPercentage,
const QList< int > &  targetAlbums,
DuplicatesSearchRestrictions  searchResultRestriction = DuplicatesSearchRestrictions::None,
SketchType  type = ScannedSketch 
)

Searches the database for the best matches for the specified query image. All matches with a similarity in a given threshold interval are returned. The threshold is in the range requiredPercentage..maximumPercentage.

References Digikam::HaarIface::Private::hasSignatureCache(), Digikam::HaarIface::Private::retrieveSignatureFromCache(), and retrieveSignatureFromDB().

Referenced by findDuplicates(), and Digikam::ItemLister::listHaarSearch().

◆ bestMatchesForSignature()

QMap< qlonglong, double > Digikam::HaarIface::bestMatchesForSignature ( const QString &  signature,
const QList< int > &  targetAlbums,
int  numberOfResults = 20,
SketchType  type = ScannedSketch 
)

◆ findDuplicates()

HaarIface::DuplicatesResultsMap Digikam::HaarIface::findDuplicates ( const QSet< qlonglong > &  images2Scan,
const QSet< qlonglong >::const_iterator &  rangeBegin,
const QSet< qlonglong >::const_iterator &  rangeEnd,
double  requiredPercentage,
double  maximumPercentage,
DuplicatesSearchRestrictions  searchResultRestriction = DuplicatesSearchRestrictions::None,
HaarProgressObserver *const  observer = nullptr 
)

Fill a map of duplicates images found over a list of images to scan. For each map item, the result values is list of candidate images which are duplicates of the key image. All images are referenced by id from database. The threshold is in the range 0..1, with 1 meaning identical signature.

References bestMatchesForImageWithThreshold(), Digikam::ItemInfo::dateTime(), Digikam::ItemInfo::dimensions(), Digikam::ItemInfo::fileSize(), Digikam::HaarIface::Private::hasSignatureCache(), Digikam::HaarProgressObserver::imageProcessed(), Digikam::HaarProgressObserver::isCanceled(), Digikam::HaarIface::Private::rebuildSignatureCache(), ScannedSketch, and Digikam::HaarIface::Private::signatureCache().

◆ fulfillsRestrictions()

bool Digikam::HaarIface::fulfillsRestrictions ( qlonglong  imageId,
int  albumId,
qlonglong  originalImageId,
int  originalAlbumId,
const QList< int > &  targetAlbums,
DuplicatesSearchRestrictions  searchResultRestriction 
)

Checks whether the image with the given imageId fulfills all restrictions given in targetAlbums and in respect to searchResultRestriction.

References DifferentAlbum, None, and SameAlbum.

◆ getBestAndWorstPossibleScore()

void Digikam::HaarIface::getBestAndWorstPossibleScore ( Haar::SignatureData *const  querySig,
SketchType  type,
double *const  lowestAndBestScore,
double *const  highestAndWorstScore 
)

For a given signature, find out the highest and lowest possible score that any other signature could reach, compared to the given signature.

References Digikam::Haar::SignatureData::avg, Digikam::Haar::WeightBin::binAbs(), Digikam::Haar::NumberOfCoefficients, Digikam::Haar::SignatureData::sig, Digikam::Haar::Weights::weight(), Digikam::HaarIface::Private::weightBin, and Digikam::Haar::Weights::weightForAverage().

◆ imagesFromAlbumsAndTags()

QSet< qlonglong > Digikam::HaarIface::imagesFromAlbumsAndTags ( const QList< int > &  albums2Scan,
const QList< int > &  tags2Scan,
AlbumTagRelation  relation 
)
static

Collects all images from the given album and tag ids according to their relation.

References AlbumExclusive, Digikam::CoreDbAccess::db(), Digikam::CoreDB::getItemIDsInAlbum(), Digikam::CoreDB::getItemIDsInTag(), Intersection, NoMix, TagExclusive, and Union.

◆ indexImage() [1/5]

bool Digikam::HaarIface::indexImage ( const QString &  filename)

Adds an image to the index in the database.

References loadQImage().

Referenced by Digikam::SearchModificationHelper::createFuzzySearchFromImage(), indexImage(), and Digikam::FingerprintsTask::run().

◆ indexImage() [2/5]

bool Digikam::HaarIface::indexImage ( const QString &  filename,
const DImg image 
)

◆ indexImage() [3/5]

bool Digikam::HaarIface::indexImage ( const QString &  filename,
const QImage &  image 
)

◆ indexImage() [4/5]

bool Digikam::HaarIface::indexImage ( qlonglong  imageid,
const DImg image 
)

◆ indexImage() [5/5]

bool Digikam::HaarIface::indexImage ( qlonglong  imageid,
const QImage &  image 
)

◆ loadQImage()

QImage Digikam::HaarIface::loadQImage ( const QString &  filename)

This method loads a QImage from the given filename.

Parameters
filenamethe name of the file (path)
Returns
A QImage, non-null on success.

References Digikam::JPEGUtils::isJpegImage(), Digikam::JPEGUtils::loadJPEGScaled(), and Digikam::Haar::NumberOfPixels.

Referenced by Digikam::FuzzySearchView::dropEvent(), and indexImage().

◆ preferredSize()

int Digikam::HaarIface::preferredSize ( )
static

◆ rebuildDuplicatesAlbums()

void Digikam::HaarIface::rebuildDuplicatesAlbums ( const DuplicatesResultsMap results,
bool  isAlbumUpdate 
)
static

This method rebuilds the given SAlbums using the given results.

Parameters
resultsMap of duplicates images found over a list of images.

References Digikam::CoreDB::addSearch(), Digikam::CoreDbAccess::db(), Digikam::CoreDB::deleteSearch(), Digikam::CoreDB::deleteSearches(), and Digikam::DatabaseSearch::DuplicatesSearch.

Referenced by Digikam::SearchesDBJobsThread::slotDuplicatesResults().

◆ retrieveSignatureFromDB()

bool Digikam::HaarIface::retrieveSignatureFromDB ( qlonglong  imageid,
Haar::SignatureData sig 
)

Retrieve the Haar signature from database using image id. Return true if item signature exist else false.

References Digikam::SimilarityDbAccess::backend(), Digikam::BdEngineBackend::execSql(), and Digikam::DatabaseBlob::read().

Referenced by bestMatchesForImageWithThreshold().

◆ setAlbumRootsToSearch() [1/2]

void Digikam::HaarIface::setAlbumRootsToSearch ( const QList< int > &  albumRootIds)

Give a list of albumRoots to which the search shall be limited. Calling with an empty list will disable filtering.

Referenced by Digikam::ItemLister::listHaarSearch().

◆ setAlbumRootsToSearch() [2/2]

void Digikam::HaarIface::setAlbumRootsToSearch ( const QSet< int > &  albumRootIds)

◆ signatureAsText()

QString Digikam::HaarIface::signatureAsText ( const QImage &  image)

Calculates the Haar signature, bring it in a form as stored in the DB, and encode it to Ascii data. Can be used for bestMatchesForSignature.

References Digikam::Haar::Calculator::calcHaar(), Digikam::HaarIface::Private::imageData(), Digikam::HaarIface::Private::setImageDataFromImage(), Digikam::Haar::Calculator::transform(), and Digikam::DatabaseBlob::write().

Referenced by Digikam::SearchModificationHelper::createFuzzySearchFromSketch().


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