~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to extra/libkface/libkface/recognitiondatabase.h

  • Committer: Package Import Robot
  • Author(s): Felix Geyer, Rohan Garg, Philip Muškovac, Felix Geyer
  • Date: 2011-09-23 18:18:55 UTC
  • mfrom: (1.2.36 upstream)
  • Revision ID: package-import@ubuntu.com-20110923181855-ifs67wxkugshev9k
Tags: 2:2.1.1-0ubuntu1
[ Rohan Garg ]
* New upstream release (LP: #834190)
  - debian/control
    + Build with libqtwebkit-dev
 - debian/kipi-plugins-common
    + Install libkvkontakte required by kipi-plugins
 - debian/digikam
    + Install panoramagui

[ Philip Muškovac ]
* New upstream release
  - debian/control:
    + Add libcv-dev, libcvaux-dev, libhighgui-dev, libboost-graph1.46-dev,
      libksane-dev, libxml2-dev, libxslt-dev, libqt4-opengl-dev, libqjson-dev,
      libgpod-dev and libqca2-dev to build-deps
    + Add packages for kipi-plugins, libmediawiki, libkface, libkgeomap and
      libkvkontakte
  - debian/rules:
    + Don't build with gphoto2 since it doesn't build with it.
  - Add kubuntu_fix_test_linking.diff to fix linking of the dngconverter test
  - update install files
  - update kubuntu_01_mysqld_executable_name.diff for new cmake layout
    and rename to kubuntu_mysqld_executable_name.diff
* Fix typo in digikam-data description (LP: #804894)
* Fix Vcs links

[ Felix Geyer ]
* Move library data files to the new packages libkface-data, libkgeomap-data
  and libkvkontakte-data.
* Override version of the embedded library packages to 1.0~digikam<version>.
* Exclude the library packages from digikam-dbg to prevent file conflicts in
  the future.
* Call dh_install with --list-missing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** ===========================================================
 
2
 * @file
 
3
 *
 
4
 * This file is a part of digiKam project
 
5
 * <a href="http://www.digikam.org">http://www.digikam.org</a>
 
6
 *
 
7
 * @date  2010-09-02
 
8
 * @brief Wrapper class for face recongition
 
9
 *
 
10
 * @author Copyright (C) 2010 by Marcel Wiesweg
 
11
 *         <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a>
 
12
 * @author Copyright (C) 2010 by Aditya Bhatt
 
13
 *         <a href="mailto:adityabhatt1991 at gmail dot com">adityabhatt1991 at gmail dot com</a>
 
14
 * @author Copyright (C) 2010 by Gilles Caulier
 
15
 *         <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
 
16
 *
 
17
 * This program is free software; you can redistribute it
 
18
 * and/or modify it under the terms of the GNU General
 
19
 * Public License as published by the Free Software Foundation;
 
20
 * either version 2, or (at your option)
 
21
 * any later version.
 
22
 *
 
23
 * This program is distributed in the hope that it will be useful,
 
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
26
 * GNU General Public License for more details.
 
27
 *
 
28
 * ============================================================ */
 
29
 
 
30
#ifndef KFACE_RECOGNITIONDATABASE_H
 
31
#define KFACE_RECOGNITIONDATABASE_H
 
32
 
 
33
// Qt includes
 
34
 
 
35
#include <QtCore/QExplicitlySharedDataPointer>
 
36
 
 
37
// KDE includes
 
38
 
 
39
#include <kstandarddirs.h>
 
40
 
 
41
// Local includes
 
42
 
 
43
#include "libkface_export.h"
 
44
#include "face.h"
 
45
#include "image.h"
 
46
 
 
47
namespace KFaceIface
 
48
{
 
49
 
 
50
class KFACE_EXPORT RecognitionDatabase
 
51
{
 
52
 
 
53
public:
 
54
 
 
55
    /**
 
56
     * A wrapper around Database for face recongition.
 
57
     * Additionally provides the following guarantees:
 
58
     * - deferred creation: The backend is created only when used first.
 
59
     * - only one instance per configuration path is created
 
60
     * - an instance of this class is thread-safe
 
61
     *   (this class is also reentrant, for different objects and paths)
 
62
     */
 
63
 
 
64
    /**
 
65
     * Returns an instance of RecognitionDatabase for the given configuration path.
 
66
     * When called multiple times with the same path, will return the same database.
 
67
     * The database is closed and configuration written after the last object is destroyed.
 
68
     * @param configurationPath The path where the RecognitionDatabase configuration file will be stored.
 
69
     * If null, a default path is located by KStandardDirs.
 
70
     */
 
71
    static RecognitionDatabase addDatabase(const QString& configurationPath = QString());
 
72
 
 
73
    /// Constructs a null database
 
74
    RecognitionDatabase();
 
75
 
 
76
    RecognitionDatabase(const RecognitionDatabase& other);
 
77
    ~RecognitionDatabase();
 
78
    RecognitionDatabase& operator=(const RecognitionDatabase& other);
 
79
 
 
80
    bool isNull() const;
 
81
 
 
82
    /**
 
83
     * Explicitly save configuration. Automatically done in destructor.
 
84
     */
 
85
    void saveConfig();
 
86
 
 
87
    /**
 
88
     * Update the training database with a QList of Faces which hold the face images
 
89
     * Faces that have not been given any ID by the caller will automatically be given the next available ID,
 
90
     * and this ID will be updated in the Face objects.
 
91
     * @param faces A QList of Face's, which hold the face image too, for updating the DB.
 
92
     * @return False if no faces were updated, due to an argument of size zero
 
93
     */
 
94
    bool updateFaces(QList<Face>& faces);
 
95
 
 
96
    /**
 
97
     * Function to recognize faces in a QList of Faces which hold the face images.
 
98
     * Recognized faces will have their ID's changed in the Face objects
 
99
     * @param faces A QList of Face's, which hold the face image too, for recongition.
 
100
     * @return A QList of "closeness" of recognized faces, in the same order as the argument;
 
101
     * or an empty list, if an error occurred or no recognition data is available.
 
102
     */
 
103
    QList<double> recognizeFaces(QList<Face>& faces);
 
104
 
 
105
    /**
 
106
     * Clear the training database for a single name or id.
 
107
     * Use with care, this can deleted carefully accumulated data!
 
108
     */
 
109
    void clearTraining(const QString& name);
 
110
    void clearTraining(int id);
 
111
    void clearAllTraining();
 
112
 
 
113
    /**
 
114
     * Returns the directory path of the config file
 
115
     *
 
116
     */
 
117
    QString configPath() const;
 
118
 
 
119
    /**
 
120
     * Get the number of people in the database
 
121
     * @return Number of unique ID's in the database
 
122
     */
 
123
    int peopleCount() const;
 
124
 
 
125
    /**
 
126
     * Returns all ids in the database
 
127
     */
 
128
    QList<int> allIds() const;
 
129
 
 
130
    /**
 
131
     * Returns all names in the database
 
132
     */
 
133
    QStringList allNames() const;
 
134
 
 
135
    /**
 
136
     * Returns the first name associated with the given id, or
 
137
     * a null string. Note there may be multiple names per id.
 
138
     */
 
139
    QString nameForId(int id) const;
 
140
 
 
141
    /**
 
142
     * Returns the id for the given name, or -1 if this name is not know.
 
143
     */
 
144
    int idForName(const QString& name) const;
 
145
 
 
146
    /**
 
147
     * Returns the recommended size if you want to scale images for recognition.
 
148
     * Larger images can be passed, but may be downscaled.
 
149
     */
 
150
    QSize recommendedImageSize(const QSize& availableSize = QSize()) const;
 
151
 
 
152
private:
 
153
 
 
154
    class RecognitionDatabasePriv;
 
155
 
 
156
    RecognitionDatabase(QExplicitlySharedDataPointer<RecognitionDatabasePriv> d);
 
157
 
 
158
    QExplicitlySharedDataPointer<RecognitionDatabasePriv> d;
 
159
 
 
160
    friend class RecognitionDatabaseStaticPriv;
 
161
};
 
162
 
 
163
} // namespace KFaceIface
 
164
 
 
165
#endif // KFACE_RECOGNITIONDATABASE_H