2036db308450cddcac0bbf7e1e5a4e2a1dc00f56
[framework/osp/vision.git] / inc / FUixVisionImageFeatureManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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
19 /**
20  * @file     FUixVisionImageFeatureManager.h
21  * @brief    This is the header file for the %Tizen::Uix::Vision::ImageFeatureManager class.
22  */
23
24 #ifndef _FUIX_VISION_IMAGE_FEATURE_MANAGER_H_
25 #define _FUIX_VISION_IMAGE_FEATURE_MANAGER_H_
26 #include <FBaseObject.h>
27 #include <FBase.h>
28 #include <FGrpBitmap.h>
29 #include <FUixVisionImageFeatureInfo.h>
30 #include <FMedia.h>
31
32 namespace Tizen { namespace Uix { namespace Vision
33 {
34
35 /**
36  * @class    ImageFeatureManager
37  * @brief    This class provides methods to generate individual feature data from individual image data.
38  *           And this class also provides method to manage image feature set which is the collection of individual feature data.
39  *
40  * @since    2.1
41  *
42  * The %ImageFeatureManager class provides the ability to generate individual image feature data and manage image feature set.
43  *
44  * The following example demonstrates how to use the %ImageFeatureManager class.
45  *
46  * @code
47  * void GenerateImageFeatureSet()
48  * {
49  *     Tizen::Uix::Vision::ImageFeatureManager imageFeatureManager;
50  *     imageFeatureManager.Construct();
51  *     imageFeatureManager.Load("/opt/usr/media/Images/testFeatureSet.xdb");
52  *     imageFeatureManager.AddFeature("/opt/usr/media/Images/image1.jpg");
53  *     imageFeatureManager.AddFeature("/opt/usr/media/Images/image2.jpg");
54  *     imageFeatureManager.AddFeature("/opt/usr/media/Images/image3.jpg");
55  *     imageFeatureManager.Flush();
56  * }
57  * @endcode
58  */
59 class _OSP_EXPORT_ ImageFeatureManager
60     : public Tizen::Base::Object
61 {
62 public:
63
64     /**
65      * This is the default constructor for this class.
66      * The object is not fully constructed after this constructor is called.
67      * For full construction, the Construct() method must be called right after calling this constructor.
68      *
69      * @since    2.1
70      */
71     ImageFeatureManager(void);
72
73     /**
74      * This is the destructor for this class. @n
75      * The resources are deallocated by this method.
76      * This destructor overrides Tizen::Base::Object::~Object().
77      *
78      * @since    2.1
79      */
80     ~ImageFeatureManager(void);
81
82     /**
83      * Initialize this instance of ImageFeatureManager and create image feature set.
84      * Every application must call Construct() before calling any other method of ImageFeatureManager.
85      *
86      * @since       2.1
87      *
88      * @feature     %http://tizen.org/feature/vision.image_recognition
89      *
90      * @return      An error code.
91      *
92      * @exception   E_SUCCESS          The method is successful.
93      * @exception   E_UNSUPPORTED_OPERATION   The Emulator or target device does not support the required feature. 
94      * For more information, see <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">Application Filtering</a>.
95      * @remarks     Before calling this method, check whether the feature is supported by %Tizen::System::SystemInfo::GetValue() methods.
96      * @see
97      */
98     result Construct(void);
99
100     /**
101      * Loads feature set file
102      *
103      * @since       2.1
104      *
105      * @return      An error code.
106      *
107      * @param[in]   featureSetFilePath       Feature set file path
108      *
109      * @exception   E_SUCCESS                The method is successful.
110      * @exception   E_INVALID_ARG            A specified feature set file path is invalid.
111      * @exception   E_OUT_OF_MEMORY          The memory is insufficient.
112      *
113      * @remarks     if feature set file exists, it will be updated.
114      *              if feature set file does not exist, it will return E_INVALID_ARG exception.
115      * @see
116      */
117     result Load(const Tizen::Base::String& featureSetFilePath);
118
119     /**
120      * Returns list of supported image file formats for adding feature.
121      *
122      * @since       2.1
123      * @return      list of supported image file formats
124      *
125      * @see
126      */
127     static Tizen::Base::Collection::IListT<Tizen::Media::ImageFormat>* GetSupportedImageFileFormatsListN(void);
128
129     /**
130      * Adds a feature to feature set
131      *
132      * @since       2.1
133      *
134      * @return      Feature index of newly created feature on success, otherwise returns -1.
135      *
136      * @param[in]   imagePath            Input image file path
137      *
138      * @exception   E_INVALID_ARG        A specified input parameter is invalid.
139      *
140      * @remarks     The specific error code can be accessed using the GetLastResult() method.
141      *              Input image file must be one of the supported image file formats.
142      *              Calling this method actually means 'Mark As Add Feature'.
143      *              And the marked feature data will be added to feature set file after calling Flush();
144      * @see         GetSupportedImageFileFormatsListN(void)
145      *              Flush(const Tizen::Base::String* featureSetFilePath = 0);
146      */
147     int AddFeature(const Tizen::Base::String& imagePath);
148
149     /**
150      * Adds a feature to feature set
151      *
152      * @since       2.1
153      *
154      * @return      Feature index of newly created feature on success, otherwise returns -1.
155      *
156      * @param[in]   imageBuffer              Image buffer of grayscale image data of specified width and height
157      * @param[in]   width                    Width of input image
158      * @param[in]   height                   Height of input image
159      * @param[in]   description              Description of the feature
160      *
161      * @exception   E_INVALID_ARG            A specified input parameter is invalid.
162      *
163      * @remarks     The specific error code can be accessed using the GetLastResult() method.
164      *              Calling this method actually means 'Mark As Add Feature'.
165      *              And the marked feature data will be added to feature set file after calling Flush();
166      * @see         Flush(const Tizen::Base::String* featureSetFilePath = 0);
167      */
168     int AddFeature(const Tizen::Base::ByteBuffer& imageBuffer, int width, int height, const Tizen::Base::String& description);
169
170     /**
171      * Gets total number of features in feature set.
172      *
173      * @since       2.1
174      *
175      * @return      Total number of features in the feature set.
176      * @see
177      */
178     int GetTotalNumberOfFeatures(void);
179
180     /**
181      * Deletes a feature of specified index in the feature set
182      *
183      * @since       2.1
184      *
185      * @return      An error code.
186      *
187      * @param[in]   featureIndex             Feature index in feature set
188      *
189      * @exception   E_SUCCESS                The method is successful.
190      * @exception   E_INVALID_ARG            A specified input parameter is invalid.
191      * @exception   E_OUT_OF_MEMORY          The memory is insufficient.
192      *
193      * @remarks     Calling this method actually means 'Mark As Delete Feature'.
194      *              And the marked feature data will be deleted after calling Flush();
195      * @see         Flush(const Tizen::Base::String* featureSetFilePath = 0);
196      */
197     result DeleteFeature(int featureIndex);
198
199     /**
200      * Deletes all features in feature set
201      *
202      * @since       2.1
203      *
204      * @return      An error code.
205      *
206      * @exception   E_SUCCESS          The method is successful.
207      * @exception   E_OUT_OF_MEMORY    The memory is insufficient.
208      *
209      * @remarks     Calling this method actually means 'Mark As Delete All Features'.
210      *              And all feature data will be deleted after calling Flush();
211      * @see         Flush(const Tizen::Base::String* featureSetFilePath = 0);
212      */
213     result DeleteAllFeatures(void);
214
215     /**
216      * Saves features into feature set file and update all changes as marked.
217      *
218      *
219      * @since       2.1
220      *
221      * @return      An error code.
222      *
223      * @param[in]   featureSetFilePath   Feature set file path
224      * @exception   E_SUCCESS            The method is successful.
225      * @exception   E_INVALID_ARG        A specified Feature set path is invalid.
226      *
227      * @remarks     All changes in feature set file by 'AddFeature' or 'DeleteFeature' or 'DeleteAllFeatures' are updated by calling this Flush() method.
228      *              If featureSetFilePath is not decided or is same to file path used in Load(), the loaded feature set file will be updated.
229      *              If featureSetFilePath is not same to file path used in Load(), the loaded feature set file is remained and new feature set file will be created.
230      *              If featureSetFilePath is null, the feature set file loaded by Load() method will be overwritten.
231          *                      If featureSetFilePath is not decided or is same to file path used in Load() and the loaded feature set file is read-only E_INVALID_ARG exception will be  returned.
232      *
233      * @see
234      */
235     result Flush(const Tizen::Base::String* featureSetFilePath = null);
236
237     /**
238      * Gets information of the individual feature
239      *
240      * @since       2.1
241      *
242      * @return      pointer to ImageFeatureInfo
243      *
244      * @param[in]   index       Feature index in feature set.
245      * @see
246      */
247     const Tizen::Uix::Vision::ImageFeatureInfo* GetImageFeatureInfo(int featureIndex) const;
248
249
250 private:
251     /**
252      * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
253      */
254     ImageFeatureManager(const ImageFeatureManager&);
255
256     /**
257      * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
258      */
259     ImageFeatureManager& operator=(const ImageFeatureManager&);
260
261 private:
262     class  _ImageFeatureManagerImpl* __pImageFeatureManagerImpl;
263     friend class _ImageFeatureManagerImpl;
264   };
265
266 } } } //Tizen::Uix::Vision
267
268 #endif // _FUIX_VISION_IMAGE_FEATURE_MANAGER_H_