digiKam
|
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) |
using Digikam::HaarIface::DuplicatesResultsMap = QMap<qlonglong, QPair<double, QList<qlonglong> > > |
|
explicit |
|
explicit |
Digikam::HaarIface::~HaarIface | ( | ) |
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().
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().
QMap< qlonglong, double > Digikam::HaarIface::bestMatchesForSignature | ( | const QString & | signature, |
const QList< int > & | targetAlbums, | ||
int | numberOfResults = 20 , |
||
SketchType | type = ScannedSketch |
||
) |
References Digikam::DatabaseBlob::read().
Referenced by Digikam::ItemLister::listHaarSearch().
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().
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.
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().
|
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.
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().
bool Digikam::HaarIface::indexImage | ( | const QString & | filename, |
const DImg & | image | ||
) |
bool Digikam::HaarIface::indexImage | ( | const QString & | filename, |
const QImage & | image | ||
) |
bool Digikam::HaarIface::indexImage | ( | qlonglong | imageid, |
const DImg & | image | ||
) |
bool Digikam::HaarIface::indexImage | ( | qlonglong | imageid, |
const QImage & | image | ||
) |
References indexImage(), and Digikam::HaarIface::Private::setImageDataFromImage().
Referenced by indexImage().
QImage Digikam::HaarIface::loadQImage | ( | const QString & | filename | ) |
This method loads a QImage from the given filename.
filename | the name of the file (path) |
References Digikam::JPEGUtils::isJpegImage(), Digikam::JPEGUtils::loadJPEGScaled(), and Digikam::Haar::NumberOfPixels.
Referenced by Digikam::FuzzySearchView::dropEvent(), and indexImage().
|
static |
References Digikam::Haar::NumberOfPixels.
Referenced by Digikam::FingerprintsTask::run().
|
static |
This method rebuilds the given SAlbums using the given results.
results | Map 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().
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().
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().
void Digikam::HaarIface::setAlbumRootsToSearch | ( | const QSet< int > & | albumRootIds | ) |
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().