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 FUixVisionImageRecognizer.h
21 * @brief This is the header file for the %ImageRecognizer class.
23 * This header file contains the declarations of the %ImageRecognizer class.
26 #ifndef _FUIX_VISION_IMAGE_RECOGNIZER_H_
27 #define _FUIX_VISION_IMAGE_RECOGNIZER_H_
28 #include <FBaseObject.h>
30 #include <FUixVisionImageObject.h>
32 namespace Tizen { namespace Uix { namespace Vision
34 class ImageFeatureManager;
36 * @class ImageRecognizer
37 * @brief This class provides methods to find similar image objects that are used as the input images to the feature set that stores the features of the reference images.
41 * The %ImageRecognizer class provides methods to find similar image objects that are used as the input images to the feature set that stores the features of the reference images.
42 * This class also provides methods to calculate the 2D position and 3D pose transform matrix of the recognized image objects.
44 * The following example demonstrates how to use the %ImageRecognizer class.
49 * #include <FGraphics.h>
53 * using namespace Tizen::Base;
54 * using namespace Tizen::Media;
55 * using namespace Tizen::Graphics;
56 * using namespace Tizen::Io;
57 * using namespace Tizen::Uix::Vision;
59 * : ICameraEventListener
64 * result Initialize(void);
66 * // Called when camera auto focus occurred
67 * void OnCameraAutoFocused(bool completeCondition);
68 * // Called when camera preview occurred
69 * void OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r);
70 * // Called when camera captured image
71 * void OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData, result r);
72 * // Called when camera error occurred
73 * void OnCameraErrorOccurred(Tizen::Media::CameraErrorReason r);
76 * ImageRecognizer* __pImageRecognizer;
77 * ImageFeatureManager* __pFeatureManager;
81 * MyClass::Initialize(void)
85 * // Creates and initializes a recognition engine
86 * __pImageRecognizer = new Tizen::Uix::Vision::ImageRecognizer();
87 * r = __pImageRecognizer->Construct();
89 * // Creates an initialized ImageFeatureManager
90 * __pFeatureManager = new Tizen::Uix::Vision::ImageFeatureManager();
91 * r = __pFeatureManager->Construct();
93 * // Loads a feature set
94 * r = __pFeatureManager->Load("/opt/usr/media/Images/testFeatureSet.xdb");
96 * // Configures the recognition engine
97 * r =__pImageRecognizer->SetFeatureManager(*__pFeatureManager);
99 * // Sets the image size to be same as the camera preview size
100 * r = __pImageRecognizer->SetImageSize(640, 480);
102 * __pImageRecognizer->SetMultiTrackingEnabled(false);
107 * // We suppose camera to be initialized with Tizen::Graphics::PIXEL_FORMAT_YCbCr420_PLANAR format
109 * MyClass::OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r)
111 * // Processes the camera image
112 * __pImageRecognizer->ProcessImage(previewedData);
114 * // Loops through all recognized images
115 * for (int i = 0; i < __pImageRecognizer->GetRecognizedObjectCount(); i++)
117 * const ImageObject *o = __pImageRecognizer->GetRecognizedObject(i);
118 * int featId = o->GetFeatureId();
125 class _OSP_EXPORT_ ImageRecognizer
126 : public Tizen::Base::Object
131 * This is the default constructor for this class. @n
132 * The object is not fully constructed after this constructor is called. @n
133 * For full construction, the Construct() method must be called right after calling this constructor.
137 ImageRecognizer(void);
140 * This is the destructor for this class. @n
141 * The resources are deallocated by this method.
142 * This destructor overrides Tizen::Base::Object::~Object().
146 ~ImageRecognizer(void);
149 * Initializes this instance of %ImageRecognizer. @n
150 * Every application must call the %Construct() method before calling any other method of %ImageRecognizer.
154 * @feature %http://tizen.org/feature/vision.image_recognition
156 * @exception E_SUCCESS The method is successful.
157 * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
158 * For more information, see <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">Application Filtering</a>.
159 * @remarks Before calling this method, check whether the feature is supported by Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
161 result Construct(void);
164 * Enables or disables the single or multiple tracking mode.
168 * @param[in] enable The boolean value that enables or disables the multiple tracking mode @n
169 * The default mode is the single tracking mode.
172 * - In the single tracking mode, only one image is recognized at a time on the screen.
173 * - In the multiple tracking mode, multiple images (maximum 3) can be recognized and tracked simultaneously.
175 void SetMultiTrackingEnabled(bool enable);
178 * Sets the width and the height of the input image.
182 * @return An error code
184 * @param[in] width The width of the input image
185 * @param[in] height The height of the input image
187 * @exception E_SUCCESS The method is successful.
188 * @exception E_INVALID_ARG A specified input parameter is invalid.
190 result SetImageSize(int width, int height);
193 * Sets the ImageFeatureManager instance for initialization.
196 * @pre The ImageFeatureManager should be initialized by loading the feature set file using the ImageFeatureManager::Load() method.
198 * @return An error code
199 * @param[in] imageFeatureManager The ImageFeatureManager instance that manages the image feature set to use for recognition
200 * @exception E_SUCCESS The method is successful.
201 * @exception E_INVALID_ARG The ImageFeatureManager is invalid.
203 * @remarks The ImageFeatureManager should be initialized by loading the feature set file.
205 result SetFeatureManager(ImageFeatureManager& imageFeatureManager);
208 * Gets the count of the recognized image object.
212 * @return The count of the recognized image object
214 * @remarks The recognized object has an index value that ranges from @c 0 to (count of the recognized image objects) @c - 1.
215 * @see GetRecognizedObject()
217 int GetRecognizedObjectCount(void);
220 * Gets the recognized image object that contains the information.
224 * @return A pointer to the ImageObject instance that includes all the information about the recognized image object
225 * @param[in] index The index of the recognized image object @n
226 * The valid range for this parameter is @c 0 to (count of the recognized image objects) @c - 1.
227 * @exception E_SUCCESS The method is successful.
229 * @see GetRecognizedObjectCount()
231 const ImageObject* GetRecognizedObject(int index) const;
234 * Processes the input image for recognition.
238 * @return An error code
240 * @param[in] imageBuffer The input image buffer @n
241 * It must be allocated externally and have a size of (width*height) set by SetImageSize().
242 * @exception E_SUCCESS The method is successful.
243 * @exception E_INVALID_ARG Either of the following conditions has occurred:
244 * - The specified @c imageBuffer is not allocated.
245 * - The size of the specified @c imageBuffer is not equal to the input image size set by SetImageSize().
246 * @exception E_OUT_OF_MEMORY The memory is insufficient.
247 * @see SetImageSize(int, int)
249 result ProcessImage(const Tizen::Base::ByteBuffer& imageBuffer);
253 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
255 ImageRecognizer(const ImageRecognizer&);
258 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
260 ImageRecognizer& operator=(const ImageRecognizer&);
263 class _ImageRecognizerImpl* __pImageRecognizerImpl; ///< implementation bridge
264 friend class _ImageRecognizerImpl;
267 } } } //Tizen::Uix::Vision
269 #endif // _FUIX_VISION_IMAGE_RECOGNIZER_H_