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 FUixVisionQrCodeRecognizer.h
21 * @brief This is the header file for the %QrCodeRecognizer class.
23 * This header file contains the declarations of the %QrCodeRecognizer class.
25 #ifndef _FUIX_VISION_QR_CODE_RECOGNIZER_H_
26 #define _FUIX_VISION_QR_CODE_RECOGNIZER_H_
27 #include <FBaseObject.h>
28 #include <FUixVisionQrCodeObject.h>
30 #include <FGraphics.h>
32 namespace Tizen { namespace Uix { namespace Vision
35 * @class QrCodeRecognizer
36 * @brief This class provides methods to recognize a QR code image.
40 * The %QrCodeRecognizer class provides methods to generate a QR code image.
42 * The following example demonstrates how to use the %QrCodeRecognizer class.
47 * #include <FGraphics.h>
51 * using namespace Tizen::Base;
52 * using namespace Tizen::Media;
53 * using namespace Tizen::Graphics;
54 * using namespace Tizen::Io;
55 * using namespace Tizen::Uix::Vision;
58 * : ICameraEventListener
63 * result Initialize(void);
65 * // Called when camera auto focus occurred
66 * void OnCameraAutoFocused(bool completeCondition);
67 * // Called when camera preview occurred
68 * void OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r);
69 * // Called when camera captured image
70 * void OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData, result r);
71 * // Called when camera error occurred
72 * void OnCameraErrorOccurred(Tizen::Media::CameraErrorReason r);
75 * QrCodeRecognizer* __pQrRecognizer;
79 * MyClass::Initialize(void)
83 * // Creates and initializes recognition engine
84 * __pQrRecognizer = new Tizen::Uix::Vision::QrCodeRecognizer();
85 * r = __pQrRecognizer->Construct();
87 * //Image size must be same as camera preview size
88 * r = __pQrRecognizer->SetImageSize(640, 480);
93 * // We suppose camera to be initialized with Tizen::Graphics::PIXEL_FORMAT_YCbCr420_PLANAR format
95 * MyClass::OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r)
97 * // Processing of the camera image follows
98 * __pQrRecognizer->ProcessImage(previewedData);
100 * // Loops through all recognized QRs
101 * for (int i = 0; i < __pQrRecognizer->GetRecognizedObjectCount(); i++)
103 * const QrCodeObject *o = __pQrRecognizer->GetRecognizedObject(i);
104 * String qrText = o->GetText();
110 class _OSP_EXPORT_ QrCodeRecognizer
111 : public Tizen::Base::Object
116 * This is the default constructor for this class. @n
117 * The object is not fully constructed after this constructor is called. @n
118 * For full construction, the Construct() method must be called right after calling this constructor.
122 QrCodeRecognizer(void);
125 * This is the destructor for this class. @n
126 * The resources are deallocated by this method.
127 * This destructor overrides Tizen::Base::Object::~Object().
131 ~QrCodeRecognizer(void);
134 * Initializes this instance of %QrCodeRecognizer. @n
135 * Every application must call %Construct() before calling any other methods of %QrCodeRecognizer.
139 * @feature %http://tizen.org/feature/vision.qrcode_recognition
141 * @exception E_SUCCESS The method is successful.
142 * @exception E_UNSUPPORTED_OPERATION The Emulator or target device does not support the required feature.
143 * For more information, see <a href="../org.tizen.gettingstarted/html/tizen_overview/application_filtering.htm">Application Filtering</a>.
144 * @remarks Before calling this method, check whether the feature is supported by
145 * Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&).
147 result Construct(void);
150 * Sets the width and height of an input image.
154 * @return An error code
156 * @param[in] width The width of the frame in pixels
157 * @param[in] height The height of the frame in pixels
158 * @exception E_SUCCESS The method is successful.
159 * @exception E_INVALID_ARG A specified input parameter is invalid.
160 * @remarks This method must be called once before calling ProcessImage().
162 result SetImageSize(int width, int height);
165 * Processes an input image for recognition.
169 * @return An error code
171 * @param[in] imageBuffer The input image buffer @n
172 * It must be allocated outside and have size of (width*height) set by SetImageSize().
173 * @exception E_SUCCESS The method is successful.
174 * @exception E_INVALID_ARG The specified @c imageBuffer is not allocated or the size of @c imageBuffer is not equal to the input image size set by SetImageSize().
175 * @exception E_OUT_OF_MEMORY The memory is insufficient.
176 * @see SetImageSize(int, int)
178 result ProcessImage(const Tizen::Base::ByteBuffer& imageBuffer);
181 * Gets the expected ROI (Region of Interest) of the recognized QR code for focusing.
185 * @return An error code
186 * @param[out] roi The expected ROI (Region of Interest) of the recognized QR code
187 * @exception E_SUCCESS The method is successful.
188 * @exception E_INVALID_ARG The specified input parameter is invalid.
190 * @remarks The ROI is used to reset camera focus to get better image and it can be obtained after calling ProcessImage() at least once.
192 result GetFocusRoi(Tizen::Graphics::Rectangle& roi);
195 * Gets a count of the recognized QR code object.
199 * @return A count of the recognized QR code object
201 * @remarks The recognized QR code object has index value from @c 0 to (count of the recognized QR code objects - 1)
202 * @see GetRecognizedObject(int)
204 int GetRecognizedObjectCount(void);
207 * Gets the recognized QR code object to get information.
211 * @return A pointer to QrCodeObject that includes all information about the recognized QR code object
212 * @param[in] index The index of the recognized QR code object @n
213 * Valid range of this parameter is @c 0 to (count of the recognized QR code objects - 1).
214 * @exception E_SUCCESS The method is successful.
216 * @see GetRecognizedObjectCount()
218 const QrCodeObject* GetRecognizedObject(int index) const;
223 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
225 QrCodeRecognizer(const QrCodeRecognizer& in);
228 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
230 QrCodeRecognizer& operator=(const QrCodeRecognizer& in);
233 class _QrCodeRecognizerImpl* __pQrCodeRecognizerImpl;
234 friend class _QrCodeRecognizerImpl;
238 } } } //Tizen::Uix::Vision
240 #endif // _FUIX_VISION_QR_CODE_RECOGNIZER_H_