2e22c4e925ee7ec29db5f0d543d87b5b35b4e77c
[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("/mnt/ums/Images/testFeatureSet.xdb");
52  *     imageFeatureManager.AddFeature("/mnt/ums/Images/image1.jpg");
53  *     imageFeatureManager.AddFeature("/mnt/ums/Images/image2.jpg");
54  *     imageFeatureManager.AddFeature("/mnt/ums/Images/image3.jpg");
55  *     imageFeatureManager.Flush();
56  * }
57  */
58 class _OSP_EXPORT_ ImageFeatureManager
59     : public Tizen::Base::Object
60 {
61 public:
62
63     /**
64      * This is the default constructor for this class.
65      * The object is not fully constructed after this constructor is called.
66      * For full construction, the Construct() method must be called right after calling this constructor.
67      *
68      * @since    2.1
69      */
70     ImageFeatureManager(void);
71
72     /**
73      * This is the destructor for this class. @n
74      * The resources are deallocated by this method.
75      * This destructor overrides Tizen::Base::Object::~Object().
76      *
77      * @since    2.1
78      */
79     ~ImageFeatureManager(void);
80
81     /**
82      * Initialize this instance of ImageFeatureManager and create image feature set.
83      * Every application must call Construct() before calling any other method of ImageFeatureManager.
84      *
85      * @since       2.1
86      *
87      * @feature     %http://tizen.org/feature/vision.image_recognition
88      *
89      * @return      An error code.
90      *
91      * @exception   E_SUCCESS          The method is successful.
92      * @exception   E_UNSUPPORTED_OPERATION   The Emulator or target device does not support the required feature. 
93      * For more information, see <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">Application Filtering</a>.
94      * @remarks     Before calling this method, check whether the feature is supported by %Tizen::System::SystemInfo::GetValue() methods.
95      * @see
96      */
97     result Construct(void);
98
99     /**
100      * Loads feature set file
101      *
102      * @since       2.1
103      *
104      * @return      An error code.
105      *
106      * @param[in]   featureSetFilePath       Feature set file path
107      *
108      * @exception   E_SUCCESS                The method is successful.
109      * @exception   E_INVALID_ARG            A specified feature set file path is invalid.
110      * @exception   E_OUT_OF_MEMORY          The memory is insufficient.
111      *
112      * @remarks     if feature set file exists, it will be updated.
113      *              if feature set file does not exist, it will be newly created.
114      * @see
115      */
116     result Load(const Tizen::Base::String& featureSetFilePath);
117
118     /**
119      * Returns list of supported image file formats for adding feature.
120      *
121      * @since       2.1
122      * @return      list of supported image file formats
123      *
124      * @see
125      */
126     static Tizen::Base::Collection::IListT<Tizen::Media::ImageFormat>* GetSupportedImageFileFormatsListN(void);
127
128     /**
129      * Adds a feature to feature set
130      *
131      * @since       2.1
132      *
133      * @return      Feature index of newly created feature on success.
134      *              If the specified input image file path is invalid, it 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.
155      *              If A specified input image file path is invalid, it returns -1.
156      *
157      * @param[in]   imageBuffer              Image buffer of grayscale image data of specified width and height
158      * @param[in]   width                    Width of input image
159      * @param[in]   height                   Height of input image
160      * @param[in]   description              Description of the feature
161      *
162      * @exception   E_INVALID_ARG            A specified input parameter is invalid.
163      *
164      * @remarks     The specific error code can be accessed using the GetLastResult() method.
165      *              Calling this method actually means 'Mark As Add Feature'.
166      *              And the marked feature data will be added to feature set file after calling Flush();
167      * @see         Flush(const Tizen::Base::String* featureSetFilePath = 0);
168      */
169     int AddFeature(const Tizen::Base::ByteBuffer& imageBuffer, int width, int height, const Tizen::Base::String& description);
170
171     /**
172      * Gets total number of features in feature set.
173      *
174      * @since       2.1
175      *
176      * @return      Total number of features in the feature set.
177      * @see
178      */
179     int GetTotalNumberOfFeatures(void);
180
181     /**
182      * Deletes a feature of specified index in the feature set
183      *
184      * @since       2.1
185      *
186      * @return      An error code.
187      *
188      * @param[in]   featureIndex             Feature index in feature set
189      *
190      * @exception   E_SUCCESS                The method is successful.
191      * @exception   E_INVALID_ARG            A specified input parameter is invalid.
192      * @exception   E_OUT_OF_MEMORY          The memory is insufficient.
193      *
194      * @remarks     Calling this method actually means 'Mark As Delete Feature'.
195      *              And the marked feature data will be deleted after calling Flush();
196      * @see         Flush(const Tizen::Base::String* featureSetFilePath = 0);
197      */
198     result DeleteFeature(int featureIndex);
199
200     /**
201      * Deletes all features in feature set
202      *
203      * @since       2.1
204      *
205      * @return      An error code.
206      *
207      * @exception   E_SUCCESS          The method is successful.
208      * @exception   E_OUT_OF_MEMORY    The memory is insufficient.
209      *
210      * @remarks     Calling this method actually means 'Mark As Delete All Features'.
211      *              And all feature data will be deleted after calling Flush();
212      * @see         Flush(const Tizen::Base::String* featureSetFilePath = 0);
213      */
214     result DeleteAllFeatures(void);
215
216     /**
217      * Saves features into feature set file and update all changes as marked.
218      *
219      *
220      * @since       2.1
221      *
222      * @return      An error code.
223      *
224      * @param[in]   featureSetFilePath   Feature set file path
225      * @exception   E_SUCCESS            The method is successful.
226      * @exception   E_INVALID_ARG        A specified Feature set path is invalid.
227      *
228      * @remarks     All changes in feature set file by 'AddFeature' or 'DeleteFeature' or 'DeleteAllFeatures' are updated by calling this Flush() method.
229      *              If featureSetFilePath is not decided or is same to file path used in Load(), the loaded feature set file will be updated.
230      *              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.
231      * @remarks     If featureSetFilePath is null, the feature set file loaded by Load() method will be overwritten.
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_