55b844c7c83e2d3a295b97177738a38b43147bfd
[platform/framework/native/vision.git] / inc / FUixVisionQrCodeRecognizer.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     FUixVisionQrCodeRecognizer.h
21  * @brief    This is the header file for the %QrCodeRecognizer class.
22  *
23  * This header file contains the declarations of the %QrCodeRecognizer class.
24  */
25 #ifndef _FUIX_VISION_QR_CODE_RECOGNIZER_H_
26 #define _FUIX_VISION_QR_CODE_RECOGNIZER_H_
27 #include <FBaseObject.h>
28 #include <FUixVisionQrCodeObject.h>
29 #include <FBase.h>
30 #include <FGraphics.h>
31
32 namespace Tizen { namespace Uix { namespace Vision
33 {
34 /**
35  * @class    QrCodeRecognizer
36  * @brief    This class provides methods to recognize a QR code image.
37  *
38  * @since    2.1
39  *
40  * The %QrCodeRecognizer class provides methods to generate a QR code image.
41  *
42  * The following example demonstrates how to use the %QrCodeRecognizer class.
43  *
44  * @code
45  * #include <FBase.h>
46  * #include <FUix.h>
47  * #include <FGraphics.h>
48  * #include <FIo.h>
49  * #include <FMedia.h>
50  * 
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;
56  * 
57  * class MyClass
58  *      : ICameraEventListener
59  * {
60  * public:
61  *      MyClass();
62  *      ~MyClass();
63  *      result Initialize(void);
64  * 
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);
73  * 
74  * private:
75  *      QrCodeRecognizer*               __pQrRecognizer;
76  * };
77  * 
78  * result
79  * MyClass::Initialize(void)
80  * {
81  *      result r;
82  * 
83  *      // Creates and initializes recognition engine
84  *      __pQrRecognizer = new Tizen::Uix::Vision::QrCodeRecognizer();
85  *      r = __pQrRecognizer->Construct();
86  * 
87  *      //Image size must be same as camera preview size
88  *      r = __pQrRecognizer->SetImageSize(640, 480);
89  * 
90  *      return r;
91  * }
92  * 
93  * // We suppose camera to be initialized with Tizen::Graphics::PIXEL_FORMAT_YCbCr420_PLANAR format
94  * void
95  * MyClass::OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r)
96  * {
97  *      // Processing of the camera image follows
98  *      __pQrRecognizer->ProcessImage(previewedData);
99  * 
100  *      // Loops through all recognized QRs
101  *      for (int i = 0; i < __pQrRecognizer->GetRecognizedObjectCount(); i++)
102  *      {
103  *              const QrCodeObject *o = __pQrRecognizer->GetRecognizedObject(i);
104  *              String qrText = o->GetText();
105  *      }
106  * }
107  *
108  * @endcode
109  */
110 class _OSP_EXPORT_ QrCodeRecognizer
111     : public Tizen::Base::Object
112 {
113 public:
114
115     /**
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.
119      *
120      * @since    2.1
121      */
122     QrCodeRecognizer(void);
123
124     /**
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().
128      *
129      * @since    2.1
130      */
131     ~QrCodeRecognizer(void);
132
133     /**
134      * Initializes this instance of %QrCodeRecognizer. @n
135      * Every application must call %Construct() before calling any other methods of %QrCodeRecognizer.
136      *
137      * @since        2.1
138      *
139      * @feature      %http://tizen.org/feature/vision.qrcode_recognition
140      *
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 %Tizen::System::SystemInfo::GetValue() methods.
145      */
146     result Construct(void);
147
148     /**
149      * Sets the width and height of an input image.
150      *
151      * @since        2.1
152      *
153      * @return       An error code
154      *
155      * @param[in]    width               The width of the frame in pixels
156      * @param[in]    height              The height of the frame in pixels
157      * @exception    E_SUCCESS           The method is successful.
158      * @exception    E_INVALID_ARG       A specified input parameter is invalid.
159      * @remarks      This method must be called once before calling ProcessImage().
160      */
161     result SetImageSize(int width, int height);
162
163     /**
164      * Processes an input image for recognition.
165      *
166      * @since        2.1
167      *
168      * @return       An error code
169      *
170      * @param[in]    imageBuffer        The input image buffer @n
171      *                                  It must be allocated outside and have size of (width*height) set by SetImageSize().
172      * @exception    E_SUCCESS          The method is successful.
173      * @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().
174      * @exception    E_OUT_OF_MEMORY    The memory is insufficient.
175      * @see          SetImageSize(int, int)
176      */
177     result ProcessImage(const Tizen::Base::ByteBuffer& imageBuffer);
178
179     /**
180      * Gets the expected ROI (Region of Interest) of the recognized QR code for focusing.
181      *
182      * @since        2.1
183      *
184      * @return       An error code
185      * @param[out]   roi                 The expected ROI (Region of Interest) of the recognized QR code
186      * @exception    E_SUCCESS           The method is successful.
187      * @exception    E_INVALID_ARG       The specified input parameter is invalid.
188      *
189      * @remarks      The ROI is used to reset camera focus to get better image and it can be obtained after calling ProcessImage() at least once.
190      */
191     result GetFocusRoi(Tizen::Graphics::Rectangle& roi);
192
193     /**
194      * Gets a count of the recognized QR code object.
195      *
196      * @since        2.1
197      *
198      * @return       A count of the recognized QR code object
199      *
200      * @remarks      The recognized QR code object has index value from @c 0 to (count of the recognized QR code objects - 1)
201      * @see          GetRecognizedObject(int)
202      */
203     int GetRecognizedObjectCount(void);
204
205     /**
206      * Gets the recognized QR code object to get information.
207      *
208      * @since        2.1
209      *
210      * @return       A pointer to QrCodeObject that includes all information about the recognized QR code object
211      * @param[in]    index          The index of the recognized QR code object @n
212      *                              Valid range of this parameter is @c 0 to (count of the recognized QR code objects - 1).
213      * @exception    E_SUCCESS      The method is successful.
214      *
215      * @see          GetRecognizedObjectCount()
216      */
217     const QrCodeObject* GetRecognizedObject(int index) const;
218
219
220 private:
221     /**
222      * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
223      */
224     QrCodeRecognizer(const QrCodeRecognizer& in);
225
226     /**
227      * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
228      */
229     QrCodeRecognizer& operator=(const QrCodeRecognizer& in);
230
231 private:
232     class _QrCodeRecognizerImpl* __pQrCodeRecognizerImpl;
233     friend class _QrCodeRecognizerImpl;
234
235 };
236
237 } } } //Tizen::Uix::Vision
238
239 #endif // _FUIX_VISION_QR_CODE_RECOGNIZER_H_