2 // Open Service Platform
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
20 * @file FUixVisionImageFeatureManager.h
21 * @brief This is the header file for the %ImageFeatureManager class.
23 * This header file contains the declarations of the %ImageFeatureManager class.
26 #ifndef _FUIX_VISION_IMAGE_FEATURE_MANAGER_H_
27 #define _FUIX_VISION_IMAGE_FEATURE_MANAGER_H_
28 #include <FBaseObject.h>
30 #include <FGrpBitmap.h>
31 #include <FUixVisionImageFeatureInfo.h>
34 namespace Tizen { namespace Uix { namespace Vision
38 * @class ImageFeatureManager
39 * @brief This class provides methods to generate individual feature data from an individual image data, and load it into a feature set file.
43 * The %ImageFeatureManager class provides methods to generate individual feature data from an individual image data.
44 * This class also provides methods to manage the image feature set which is a collection of individual feature data.
46 * The following example demonstrates how to use the %ImageFeatureManager class.
52 * #include <FGraphics.h>
56 * using namespace Tizen::Base;
57 * using namespace Tizen::Media;
58 * using namespace Tizen::Graphics;
59 * using namespace Tizen::Io;
60 * using namespace Tizen::Uix::Vision;
68 * result GenerateFeatureSet(void);
69 * result AddImageFeatureSet(void);
73 * MyClass::GenerateFeatureSet(void)
76 * ImageFeatureManager imageFeatureManager;
77 * r = imageFeatureManager.Construct();
79 * //Creates new feature sets
80 * imageFeatureManager.AddFeature("/opt/usr/media/Images/image1.jpg");
81 * imageFeatureManager.AddFeature("/opt/usr/media/Images/image2.jpg");
82 * imageFeatureManager.AddFeature("/opt/usr/media/Images/image3.jpg");
83 * r = imageFeatureManager.Flush(new String("/opt/usr/media/Images/testFeatureSet.xdb"));
89 * MyClass::AddImageFeatureSet()
92 * ImageFeatureManager imageFeatureManager;
93 * imageFeatureManager.Construct();
94 * imageFeatureManager.Load("/opt/usr/media/Images/testFeatureSet.xdb");
95 * imageFeatureManager.AddFeature("/opt/usr/media/Images/image1.jpg");
96 * imageFeatureManager.AddFeature("/opt/usr/media/Images/image2.jpg");
97 * imageFeatureManager.AddFeature("/opt/usr/media/Images/image3.jpg");
98 * r = imageFeatureManager.Flush();
104 class _OSP_EXPORT_ ImageFeatureManager
105 : public Tizen::Base::Object
110 * This is the default constructor for this class. @n
111 * The object is not fully constructed after this constructor is called. @n
112 * For full construction, the Construct() method must be called right after calling this constructor.
116 ImageFeatureManager(void);
119 * This is the destructor for this class. @n
120 * The resources are deallocated by this method.
121 * This destructor overrides Tizen::Base::Object::~Object().
125 ~ImageFeatureManager(void);
128 * Initializes this instance of %ImageFeatureManager and creates an image feature set. @n
129 * Every application must call the %Construct() method before calling any other method of %ImageFeatureManager.
133 * @feature %http://tizen.org/feature/vision.image_recognition
135 * @return An error code
137 * @exception E_SUCCESS The method is successful.
138 * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
139 * For more information, see <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">Application Filtering</a>.
140 * @remarks Before calling this method, check whether the feature is supported by Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
142 result Construct(void);
145 * Loads the feature set file.
149 * @return An error code
151 * @param[in] featureSetFilePath The feature set file path at which to load the file
153 * @exception E_SUCCESS The method is successful.
154 * @exception E_INVALID_ARG The specified @c featureSetFilePath is invalid.
155 * @exception E_OUT_OF_MEMORY The memory is insufficient.
158 * - If a feature set file exists, it is updated.
159 * - If a feature set file does not exist, it is newly created.
160 * - It is not mandatory to call this method to create a new feature set file, but the Flush() method must be called with a valid feature set file path.
162 result Load(const Tizen::Base::String& featureSetFilePath);
165 * Gets the list of supported image file formats used to add the feature.
169 * @return The list of supported image file formats
171 static Tizen::Base::Collection::IListT<Tizen::Media::ImageFormat>* GetSupportedImageFileFormatsListN(void);
174 * Adds a feature to the feature set.
178 * @return The feature index of the newly and successfully created feature, @n
179 * else @c -1 is returned
181 * @param[in] imagePath The input image file path
183 * @exception E_INVALID_ARG The specified input parameter is invalid.
186 * - The specific error code can be accessed using the GetLastResult() method.
187 * - The input image file must have one of the supported image file formats.
188 * - Calling this method actually means 'Mark As Add Feature'
189 * and the marked feature data is added to the feature set file after calling the Flush() method.
190 * @see GetSupportedImageFileFormatsListN()
192 int AddFeature(const Tizen::Base::String& imagePath);
195 * Adds a feature to the feature set.
199 * @return The feature index of the newly and successfully created feature, @n
200 * else @c -1 is returned
202 * @param[in] imageBuffer The image buffer of the grayscale image data with the specified @c width and @c height
203 * @param[in] width The width of the input image
204 * @param[in] height The height of the input image
205 * @param[in] description The description of the feature
207 * @exception E_INVALID_ARG A specified input parameter is invalid.
210 * - The specific error code can be accessed using the GetLastResult() method.
211 * - Calling this method actually means 'Mark As Add Feature'.
212 * and the marked feature data is added to the feature set file after calling the Flush() method.
213 * @see Flush(const Tizen::Base::String*)
215 int AddFeature(const Tizen::Base::ByteBuffer& imageBuffer, int width, int height, const Tizen::Base::String& description);
218 * Gets the total number of features in the feature set.
222 * @return The total number of features in the feature set
224 int GetTotalNumberOfFeatures(void);
227 * Deletes the feature at the specified index in the feature set.
231 * @return An error code
233 * @param[in] featureIndex The feature index in the feature set
235 * @exception E_SUCCESS The method is successful.
236 * @exception E_INVALID_ARG The specified input parameter is invalid.
237 * @exception E_OUT_OF_MEMORY The memory is insufficient.
239 * @remarks Calling this method actually means 'Mark As Delete Feature'.
240 * and the marked feature data is deleted after calling the Flush() method.
241 * @see Flush(const Tizen::Base::String*)
243 result DeleteFeature(int featureIndex);
246 * Deletes all the features in the feature set.
250 * @return An error code
252 * @exception E_SUCCESS The method is successful.
253 * @exception E_OUT_OF_MEMORY The memory is insufficient.
255 * @remarks Calling this method actually means 'Mark As Delete All Features'.
256 * and all the feature data is deleted after calling the Flush() method.
257 * @see Flush(const Tizen::Base::String*)
259 result DeleteAllFeatures(void);
262 * Flushes features from the feature set file and updates all the changes as marked.
267 * @return An error code
269 * @param[in] featureSetFilePath The feature set file path
270 * @exception E_SUCCESS The method is successful.
271 * @exception E_INVALID_ARG The specified @c featureSetFilePath is invalid.
274 * - All the changes in the feature set file used by the AddFeature(), DeleteFeature(), or DeleteAllFeatures() method are updated by calling this method.
275 * - If the @c featureSetFilePath is not decided or is same as the file path used in the Load() method, the loaded feature set file is updated.
276 * - If the @c featureSetFilePath is not same as the file path used by the %Load() method, the loaded feature set file is retained and a new feature set file is created.
277 * - If the @c featureSetFilePath is @c null, the feature set file loaded by the %Load() method is overwritten.
278 * - If the @c featureSetFilePath is not decided or is same as the file path used by the %Load() method, and the loaded feature set file is a read-only file, then @c E_INVALID_ARG exception is returned.
279 * - If the %Load() method is not called to create a new feature set file, this method must be called with a valid @c featureSetFilePath.
282 result Flush(const Tizen::Base::String* featureSetFilePath = null);
285 * Gets the information of the specified feature.
289 * @return A pointer to the ImageFeatureInfo instance
291 * @param[in] featureIndex The feature index in the feature set
293 const Tizen::Uix::Vision::ImageFeatureInfo* GetImageFeatureInfo(int featureIndex) const;
298 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
300 ImageFeatureManager(const ImageFeatureManager&);
303 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
305 ImageFeatureManager& operator=(const ImageFeatureManager&);
308 class _ImageFeatureManagerImpl* __pImageFeatureManagerImpl;
309 friend class _ImageFeatureManagerImpl;
312 } } } //Tizen::Uix::Vision
314 #endif // _FUIX_VISION_IMAGE_FEATURE_MANAGER_H_