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.
18 #include <FUixVisionQrCodeRecognizer.h>
19 #include "FUixVision_QrCodeRecognizerImpl.h"
20 #include <FBaseSysLog.h>
22 namespace Tizen { namespace Uix { namespace Vision
25 QrCodeRecognizer::QrCodeRecognizer(void)
26 : __pQrCodeRecognizerImpl(0)
30 QrCodeRecognizer::~QrCodeRecognizer(void)
32 if (__pQrCodeRecognizerImpl != null)
34 delete __pQrCodeRecognizerImpl;
35 __pQrCodeRecognizerImpl = null;
40 QrCodeRecognizer::Construct(void)
42 SysAssertf(__pQrCodeRecognizerImpl == null, "Already constructed! ",
43 "Calling Construct() twice or more on a same instance is not allowed for this class.");
45 std::unique_ptr<_QrCodeRecognizerImpl> pQrCodeRecognizerImpl(new (std::nothrow) _QrCodeRecognizerImpl());
46 SysTryReturn(NID_UIX, pQrCodeRecognizerImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
47 __pQrCodeRecognizerImpl = pQrCodeRecognizerImpl.release();
49 return __pQrCodeRecognizerImpl->Init() ? E_SUCCESS : E_FAILURE;
53 QrCodeRecognizer::SetImageSize(int width, int height)
55 SysAssertf(__pQrCodeRecognizerImpl != null, "Not yet constructed! Consruct() should be called before use.");
57 SysTryReturn(NID_UIX, width > 0 && height > 0, false, E_INVALID_ARG,
58 "width and height must be greater then 0. [E_INVALID_ARG]");
60 return __pQrCodeRecognizerImpl->SetFrameSize(width, height) ? E_SUCCESS : E_FAILURE;
64 QrCodeRecognizer::GetFocusRoi(Tizen::Graphics::Rectangle& roi)
66 SysAssertf(__pQrCodeRecognizerImpl != null, "Not yet constructed! Consruct() should be called before use.");
68 static int array[4] = {0};
69 result r = __pQrCodeRecognizerImpl->GetROI(array) ? E_SUCCESS : E_FAILURE;
73 roi.SetBounds(array[0], array[1], array[2] - array[0], array[3] - array[1]);
79 QrCodeRecognizer::GetRecognizedObjectCount(void)
81 SysAssertf(__pQrCodeRecognizerImpl != null, "Not yet constructed! Consruct() should be called before use.");
82 __pQrCodeRecognizerImpl->FillObjectStorage();
83 return __pQrCodeRecognizerImpl->GetRecognizedObjectsCount();
87 QrCodeRecognizer::GetRecognizedObject(int index) const
89 SysAssertf(__pQrCodeRecognizerImpl != null, "Not yet constructed! Consruct() should be called before use.");
90 return __pQrCodeRecognizerImpl->GetQrCodeObject(index);
94 QrCodeRecognizer::ProcessImage(const Tizen::Base::ByteBuffer& imageBuffer)
96 SysAssertf(__pQrCodeRecognizerImpl != null, "Not yet constructed! Consruct() should be called before use.");
98 SysTryReturn(NID_UIX, imageBuffer.GetPointer(), false, E_INVALID_ARG,
99 "image buffer must not be null. [E_INVALID_ARG]");
101 return __pQrCodeRecognizerImpl->ProcessFrame((unsigned char*) imageBuffer.GetPointer()) ? E_SUCCESS : E_FAILURE;
104 } } } //Tizen::Uix::Vision