Fix flora license version
[platform/framework/native/vision.git] / src / ImageFeatureManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #ifndef IMAGEFEATUREMANAGER_H_
19 #define IMAGEFEATUREMANAGER_H_
20
21 namespace sari2
22 {
23
24 class ImageFeatureManager
25 {
26     friend class ImageRecognizer;
27     friend class ImageFeatureInfo;
28
29 public:
30     ImageFeatureManager(void);
31     ~ImageFeatureManager(void);
32
33 public:
34     /// \breif Creates object database.
35     ///
36     /// Releases previously created DB if there is any.
37     void initDB(void);
38
39     /// Adds an object to referencing database.
40     /// \param[in] filepath Path to image on the disk.
41     /// \return index of newly created object on success, otherwise -1.
42     int addImageToDB(const char* filepath);
43
44     /// Adds an object to referencing database.
45     /// \param[in] data Buffer of grayscale 8 bit image data of specified width
46     /// and height.
47     /// \param[in] width Width of input image.
48     /// \param[in] height Height of input image.
49     /// \return index of newly created object on success, otherwise -1.
50     int addImageToDB(const unsigned char* data, int width, int height, const char* imageinfo);
51
52     /// \brief Removed object from referencing database.
53     /// \param[in] index Index of object saved in database.
54     /// \return 'true' on success.
55     bool deleteImageFromDB(int index);
56
57     /// \brief Undelete object in referencing database.
58     /// \param[in] index Index of object saved in database.
59     /// \return 'true' on success.
60     bool undeleteImageFromDB(int index);
61
62     /// \return Total number of images in database.
63     unsigned int totalNumberOfImages(void);
64
65     /// \brief Serializes database to output file.
66     /// \param[in] optimizeDatabase Specifies if database optimization is
67     /// required. Optimized database performs better, but optimization process
68     /// takes some time.
69     /// \param[in] dbpath Database file path. If equal to '0' and database was
70     /// loaded from file with 'openDB()' call, saves database to that file.
71     /// \return 'true' on success.
72     bool saveDB(bool optimizeDatabase, const char* dbPath = 0);
73
74     /// \brief Updates opened database.
75     /// \return 'true' on success.
76     bool updateDB(void);
77
78     /// \brief Loads database from input file.
79     /// \param[in] dbPath Database file path.
80     /// \return 0 on success.
81     /// \return -1 on failure.
82     /// \return -2 on readonly file.
83     int openDB(const char* dbPath);
84
85     /// \brief Delete all objects from the database.
86     void releaseDB(void);
87
88 private:
89     void* databasePtr(void) const;
90     ImageFeatureManager(const ImageFeatureManager&);
91     ImageFeatureManager& operator=(const ImageFeatureManager&);
92
93 private:
94     class ImageFeatureManagerImpl;
95     ImageFeatureManagerImpl* d; ///< implementation
96 };
97
98 }
99 #endif // IMAGEFEATUREMANAGER_H_