digiKam
haariface_p.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2003-01-17
7  * Description : Haar Database interface
8  *
9  * Copyright (C) 2016-2018 by Mario Frank <mario dot frank at uni minus potsdam dot de>
10  * Copyright (C) 2003 by Ricardo Niederberger Cabral <nieder at mail dot ru>
11  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
12  * Copyright (C) 2009-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
13  * Copyright (C) 2009-2011 by Andi Clemens <andi dot clemens at gmail dot com>
14  *
15  * This program is free software; you can redistribute it
16  * and/or modify it under the terms of the GNU General
17  * Public License as published by the Free Software Foundation;
18  * either version 2, or (at your option)
19  * any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * ============================================================ */
27 
28 #ifndef DIGIKAM_HAAR_IFACE_P_H
29 #define DIGIKAM_HAAR_IFACE_P_H
30 
31 #include "haariface.h"
32 
33 // C++ includes
34 
35 #include <fstream>
36 #include <cmath>
37 #include <cstring>
38 
39 // Qt includes
40 
41 #include <QByteArray>
42 #include <QDataStream>
43 #include <QImage>
44 #include <QImageReader>
45 #include <QMap>
46 
47 // Local includes
48 
49 #include "digikam_debug.h"
50 #include "jpegutils.h"
51 #include "dimg.h"
52 #include "iteminfo.h"
53 #include "coredbaccess.h"
54 #include "coredbtransaction.h"
55 #include "coredb.h"
56 #include "coredbbackend.h"
57 #include "coredbsearchxml.h"
58 #include "dbenginesqlquery.h"
59 #include "similaritydb.h"
60 #include "similaritydbaccess.h"
61 
62 using namespace std;
63 
64 // TODO: Always store similarities in the similaritydb
65 
66 namespace Digikam
67 {
68 
69 typedef QMap<qlonglong, Haar::SignatureData> SignatureCache;
70 typedef QMap<qlonglong, int> AlbumCache;
71 
79 class Q_DECL_HIDDEN DatabaseBlob
80 {
81 public:
82 
83  enum
84  {
85  Version = 1
86  };
87 
88 public:
89 
90  DatabaseBlob() = default;
91 
95  void read(const QByteArray& array, Haar::SignatureData& data);
96 
97  QByteArray write(Haar::SignatureData& data);
98 };
99 
100 // -----------------------------------------------------------------------------------------------------
101 
102 class Q_DECL_HIDDEN HaarIface::Private
103 {
104 public:
105 
106  explicit Private();
107  ~Private();
108 
109 public:
110 
111  void rebuildSignatureCache(const QSet<qlonglong>& imageIds = {});
112  bool hasSignatureCache() const;
113 
114  bool retrieveSignatureFromCache(qlonglong imageId, Haar::SignatureData& data);
115 
116  void setImageDataFromImage(const QImage& image);
117  void setImageDataFromImage(const DImg& image);
118 
119  SignatureCache* signatureCache() const;
120  AlbumCache* albumCache() const;
121  Haar::ImageData* imageData() const;
122 
123  void setAlbumRootsToSearch(const QSet<int>& albumRootIds);
124  const QSet<int>& albumRootsToSearch() const;
125 
126 public:
127 
128  const static QString signatureQuery;
130 
131 private:
132 
133  QScopedPointer<SignatureCache> m_signatureCache;
134  QScopedPointer<AlbumCache> m_albumCache;
135 
136  QScopedPointer<Haar::ImageData> m_data;
137 
138  QSet<int> m_albumRootsToSearch;
139 };
140 
141 } // namespace Digikam
142 
143 #endif // DIGIKAM_HAAR_IFACE_P_H
Definition: dimg.h:62
Definition: haariface_p.h:80
Definition: haariface_p.h:103
static const Haar::WeightBin weightBin
Definition: haariface_p.h:129
static const QString signatureQuery
Definition: haariface_p.h:128
Definition: haariface.h:72
Definition: haar.h:105
Definition: haar.h:119
Definition: haar.h:202
Definition: datefolderview.cpp:43
QMap< qlonglong, Haar::SignatureData > SignatureCache
Definition: haariface_p.h:69
QMap< qlonglong, int > AlbumCache
Definition: haariface_p.h:70