82e952c116139ef3df9d1cf6ba13d07c0cccbb77
[framework/osp/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 %Tizen::Uix::Vision::QrCodeRecognizer class.
22  */
23 #ifndef _FUIX_VISION_QR_CODE_RECOGNIZER_H_
24 #define _FUIX_VISION_QR_CODE_RECOGNIZER_H_
25 #include <FBaseObject.h>
26 #include <FUixVisionQrCodeObject.h>
27 #include <FBase.h>
28
29 namespace Tizen { namespace Uix { namespace Vision
30 {
31 /**
32  * @class    QrCodeRecognizer
33  * @brief    This class provides methods to generate QR code image.
34  *
35  * @since    2.1
36  *
37  * The following example demonstrates how to use the %QrCodeRecognizer class.
38  *
39  * @code
40  *
41  * // Recognition engine initialization
42  *
43  * void
44  * Tracker::Initialize()
45  *
46  * {
47  *      __pQrRecognizer = new Tizen::Uix::Vision::QrCodeRecognizer();
48  *      __pQrRecognizer->Construct();
49  *      __pQrRecognizer->SetFrameSize(CAMERA_WIDTH, CAMERA_HEIGHT);
50  * }
51  *
52  * //We suppose camera to be initialized with Tizen::Graphics::PIXEL_FORMAT_YCbCr420_PLANAR format
53  *
54  * void
55  * Tracker::OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r)
56  * {
57  *         //Processing of the camera image follows
58  *         __pQrRecognizer->ProcessFrame(previewedData);
59  *
60  *        //Loop through all recognized QRs
61  *        for (int i = 0; i < __pQrRecognizer->GetRecognizedObjectCount(); i++)
62  *        {
63  *
64  *             const Tizen::Uix::Vision::QrCodeObject *o = __pQrRecognizer->GetQrCodeObject(i);
65  *             Tizen::Base::String qrText = o->GetText();
66  *
67  *         }
68  *     }
69  * }
70  *
71  * @endcode
72  */
73 class _OSP_EXPORT_ QrCodeRecognizer
74     : public Tizen::Base::Object
75 {
76 public:
77
78     /**
79      * This is the default constructor for this class.
80      * The object is not fully constructed after this constructor is called.
81      * For full construction, the Construct() method must be called right after calling this constructor.
82      *
83      * @since    2.1
84      */
85     QrCodeRecognizer(void);
86
87     /**
88      * This is the destructor for this class. @n
89      * The resources are deallocated by this method.
90      * This destructor overrides Tizen::Base::Object::~Object().
91      *
92      * @since    2.1
93      */
94     ~QrCodeRecognizer(void);
95
96     /**
97      * Initializes this instance of ImageRecognizer.
98      * Every application must call Construct() before calling any other method of ImageRecognizer.
99      *
100      * @since        2.1
101      * @exception    E_SUCCESS          The method is successful.
102      * @exception    E_OUT_OF_MEMORY    The memory is insufficient.
103      * @see
104      */
105     result Construct(void);
106
107     /**
108      * Sets width and height of input image
109      *
110      * @since        2.1
111      *
112      * @return       An error code.
113      *
114      * @param[in]    width               frame width in pixels
115      * @param[in]    height              frame height in pixels
116      * @exception    E_SUCCESS           The method is successful.
117      * @exception    E_INVALID_ARG       A specified input parameter is invalid.
118      * @remarks      This must be called once before calling processFrame.
119      * @see
120      */
121     result SetImageSize(int width, int height);
122
123     /**
124      * Process input image for recognition
125      *
126      * @since        2.1
127      *
128      * @return       An error code.
129      *
130      * @param[in]    imageBuffer        Input image buffer
131      *                                  It must be allocated outside and have size of (width*height) by SetImageSize().
132      * @exception    E_SUCCESS          The method is successful.
133      * @exception    E_INVALID_ARG      imageBuffer is not allocated or the size of imageBuffer is not equal to input image size by SetImageSize().
134      * @exception    E_OUT_OF_MEMORY    The memory is insufficient.
135      * @see          SetImageSize(int width, int height)
136      */
137     result ProcessImage(const Tizen::Base::ByteBuffer& imageBuffer);
138
139     /**
140      * Get the expected ROI(Region of Interest) of the recognized QR code for focusing
141      *
142      * @since        2.1
143      *
144      * @return       An error code
145      * @param[out]   roi                 the expected ROI(Region of Interest) of the recognized QR code
146      * @exception    E_SUCCESS           The method is successful.
147      * @exception    E_INVALID_ARG       A specified input parameter is invalid.
148      *
149      * @remarks      The ROI is used for reset of camera foucs to get better image and it can be obtained after calling ProcessImage() at least once.
150      * @see
151      */
152     result GetFocusRoi(Tizen::Graphics::Rectangle& roi);
153
154     /**
155      * Gets the number of the recognized QR code object
156      *
157      * @since        2.1
158      *
159      * @return       Number of recognized QR code object
160      *
161      * @remarks      The recognized QR code object has index value from 0 to (number of the recognized QR code objects - 1)
162      * @see          GetRecognizedObject(int index)
163      */
164     int GetRecognizedObjectCount(void);
165
166     /**
167      * Gets the recognized QR code object to get information
168      *
169      * @since        2.1
170      *
171      * @return       The pointer of QrCodeObject including all information about the reconginzed QR code object
172      * @param[in]    index          Index of the recognized QR code object
173      *                              Valid range of this parameter is 0 to (number of the recognized QR code objects - 1).
174      * @exception    E_SUCCESS      The method is successful.
175      *
176      * @see          GetRecognizedObjectCount(void)
177      */
178     const QrCodeObject* GetRecognizedObject(int index) const;
179
180
181 private:
182     /**
183      * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
184      */
185     QrCodeRecognizer(const QrCodeRecognizer& in);
186
187     /**
188      * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
189      */
190     QrCodeRecognizer& operator=(const QrCodeRecognizer& in);
191
192 private:
193     class _QrCodeRecognizerImpl* __pQrCodeRecognizerImpl;
194     friend class _QrCodeRecognizerImpl;
195
196 };
197
198 } } } //Tizen::Uix::Vision
199
200 #endif // _FUIX_VISION_QR_CODE_RECOGNIZER_H_