--- /dev/null
+Flora License
+
+Version 1.0, May, 2012
+
+http://www.tizenopensource.org/license
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction,
+and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by
+the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and
+all other entities that control, are controlled by, or are
+under common control with that entity. For the purposes of
+this definition, "control" means (i) the power, direct or indirect,
+to cause the direction or management of such entity,
+whether by contract or otherwise, or (ii) ownership of fifty percent (50%)
+or more of the outstanding shares, or (iii) beneficial ownership of
+such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity
+exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications,
+including but not limited to software source code, documentation source,
+and configuration files.
+
+"Object" form shall mean any form resulting from mechanical
+transformation or translation of a Source form, including but
+not limited to compiled object code, generated documentation,
+and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form,
+made available under the License, as indicated by a copyright notice
+that is included in or attached to the work (an example is provided
+in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form,
+that is based on (or derived from) the Work and for which the editorial
+revisions, annotations, elaborations, or other modifications represent,
+as a whole, an original work of authorship. For the purposes of this License,
+Derivative Works shall not include works that remain separable from,
+or merely link (or bind by name) to the interfaces of, the Work and
+Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original
+version of the Work and any modifications or additions to that Work or
+Derivative Works thereof, that is intentionally submitted to Licensor
+for inclusion in the Work by the copyright owner or by an individual or
+Legal Entity authorized to submit on behalf of the copyright owner.
+For the purposes of this definition, "submitted" means any form of
+electronic, verbal, or written communication sent to the Licensor or
+its representatives, including but not limited to communication on
+electronic mailing lists, source code control systems, and issue
+tracking systems that are managed by, or on behalf of, the Licensor
+for the purpose of discussing and improving the Work, but excluding
+communication that is conspicuously marked or otherwise designated
+in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity
+on behalf of whom a Contribution has been received by Licensor and
+subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies
+with the standards set forth in the Compatibility Definition Document
+and passes the Compatibility Test Suite as defined from time to time
+by the Tizen Technical Steering Group and certified by the Tizen
+Association or its designated agent.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the
+Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+(except as stated in this section) patent license to make, have made,
+use, offer to sell, sell, import, and otherwise transfer the Work
+solely as incorporated into a Tizen Certified Platform, where such
+license applies only to those patent claims licensable by such
+Contributor that are necessarily infringed by their Contribution(s)
+alone or by combination of their Contribution(s) with the Work solely
+as incorporated into a Tizen Certified Platform to which such
+Contribution(s) was submitted. If You institute patent litigation
+against any entity (including a cross-claim or counterclaim
+in a lawsuit) alleging that the Work or a Contribution incorporated
+within the Work constitutes direct or contributory patent infringement,
+then any patent licenses granted to You under this License for that
+Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+Work or Derivative Works thereof pursuant to the copyright license
+above, in any medium, with or without modifications, and in Source or
+Object form, provided that You meet the following conditions:
+
+ 1. You must give any other recipients of the Work or Derivative Works
+ a copy of this License; and
+ 2. You must cause any modified files to carry prominent notices stating
+ that You changed the files; and
+ 3. You must retain, in the Source form of any Derivative Works that
+ You distribute, all copyright, patent, trademark, and attribution
+ notices from the Source form of the Work, excluding those notices
+ that do not pertain to any part of the Derivative Works; and
+ 4. If the Work includes a "NOTICE" text file as part of its distribution,
+ then any Derivative Works that You distribute must include a readable
+ copy of the attribution notices contained within such NOTICE file,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works, in at least one of the following places:
+ within a NOTICE text file distributed as part of the Derivative Works;
+ within the Source form or documentation, if provided along with the
+ Derivative Works; or, within a display generated by the Derivative Works,
+ if and wherever such third-party notices normally appear.
+ The contents of the NOTICE file are for informational purposes only
+ and do not modify the License.
+
+You may add Your own attribution notices within Derivative Works
+that You distribute, alongside or as an addendum to the NOTICE text
+from the Work, provided that such additional attribution notices
+cannot be construed as modifying the License. You may add Your own
+copyright statement to Your modifications and may provide additional or
+different license terms and conditions for use, reproduction, or
+distribution of Your modifications, or for any such Derivative Works
+as a whole, provided Your use, reproduction, and distribution of
+the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+any Contribution intentionally submitted for inclusion in the Work
+by You to the Licensor shall be under the terms and conditions of
+this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify
+the terms of any separate license agreement you may have executed
+with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+names, trademarks, service marks, or product names of the Licensor,
+except as required for reasonable and customary use in describing the
+origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+agreed to in writing, Licensor provides the Work (and each
+Contributor provides its Contributions) on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied, including, without limitation, any warranties or conditions
+of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+PARTICULAR PURPOSE. You are solely responsible for determining the
+appropriateness of using or redistributing the Work and assume any
+risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+whether in tort (including negligence), contract, or otherwise,
+unless required by applicable law (such as deliberate and grossly
+negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special,
+incidental, or consequential damages of any character arising as a
+result of this License or out of the use or inability to use the
+Work (including but not limited to damages for loss of goodwill,
+work stoppage, computer failure or malfunction, or any and all
+other commercial damages or losses), even if such Contributor
+has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+the Work or Derivative Works thereof, You may choose to offer,
+and charge a fee for, acceptance of support, warranty, indemnity,
+or other liability obligations and/or rights consistent with this
+License. However, in accepting such obligations, You may act only
+on Your own behalf and on Your sole responsibility, not on behalf
+of any other Contributor, and only if You agree to indemnify,
+defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason
+of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following
+boilerplate notice, with the fields enclosed by brackets "[]"
+replaced with your own identifying information. (Don't include
+the brackets!) The text should be enclosed in the appropriate
+comment syntax for the file format. We also recommend that a
+file or class name and description of purpose be included on the
+same "printed page" as the copyright notice for easier
+identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Flora License, Version 1.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.tizenopensource.org/license
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
--- /dev/null
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Flora License, Version 1.
+Please, see the LICENSE file for Flora License terms and conditions.
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/xsl" href="../../../../description.xsl"?>
+
+<Overview version="0.17.1">
+ <SampleName> QrCodeRecognizer </SampleName>
+ <SampleVersion>1.0</SampleVersion>
+ <Preview>screenshot.png</Preview>
+ <Description>The QrCodeRecognizer sample application demonstrates how you can enable your device to recognize and track QR codes.
+ </Description>
+</Overview>
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#ifndef CAMERA_TOOLS_H_
+#define CAMERA_TOOLS_H_
+
+#include <FMedia.h>
+
+class CameraTools
+{
+
+private:
+ CameraTools();
+ CameraTools(const CameraTools&);
+ CameraTools& operator=(const CameraTools&);
+ ~CameraTools();
+
+public:
+
+ //Does all necessary initialization
+ static bool StartCamera(Tizen::Media::ICameraEventListener &listener,
+ const unsigned int width, const unsigned int height);
+
+ //Stops camera
+ static void StopCamera(void);
+
+ static void Suspend(void);
+
+ static void Restart(void);
+
+ static void ZoomIn(void);
+
+ static void ZoomOut(void);
+
+ static Tizen::Media::Camera* GetCamera(void);
+
+ static int GetWidth(void);
+ static int GetHeight(void);
+
+private:
+
+ static Tizen::Media::Camera* __pCamera;
+ static Tizen::Graphics::Dimension __choosenResolution;
+ static int __width;
+ static int __height;
+};
+
+#endif //CAMERA_TOOLS_H_
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#ifndef CONTROL_MANAGER_H
+#define CONTROL_MANAGER_H
+
+#include <FBase.h>
+#include <FUi.h>
+
+class ControlManager
+{
+
+private:
+ ControlManager(void);
+ ControlManager(const ControlManager&);
+ ControlManager& operator=(const ControlManager&);
+public:
+ virtual ~ControlManager(void);
+
+ void ShowText(Tizen::Base::String);
+ void ShowUrl(Tizen::Base::String);
+ void ShowSms(Tizen::Base::String, Tizen::Base::String);
+ void ShowContact(Tizen::Base::String);
+ void ShowCall(Tizen::Base::String);
+ void ShowEmail(Tizen::Base::String);
+
+ static ControlManager* GetInstance(void);
+
+private:
+ Tizen::Base::Object* Run(void);
+ void StartControl(void);
+
+ Tizen::Base::String __provider;
+ Tizen::Base::String __operation;
+
+ Tizen::Base::Collection::HashMap __data;
+
+
+private:
+ static const int ID_BUTTON_YES = 501;
+ static const int ID_BUTTON_NO = 502;
+
+};
+
+
+#endif
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+
+#ifndef CUBES_H_
+#define CUBES_H_
+
+/* 3D data. Vertex range -0.5..0.5 in all axes.
+* Z -0.5 is near, 0.5 is far. */
+const float halfSizeofCube = 0.25;
+const float halfSizeofPlane = 0.5f;
+const float cubeHeight = 0.5;
+
+
+const float leftTransform[16] = {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, -1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.2f
+};
+
+const float rightTransform[16] = {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, -1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 2.0f
+};
+
+const float aVertices[] =
+{
+ /* Front face. */
+ /* Bottom left */
+ -halfSizeofPlane, halfSizeofPlane, 0,
+ -halfSizeofPlane, -halfSizeofPlane, 0,
+ halfSizeofPlane, -halfSizeofPlane, 0,
+ /* Top right */
+ -halfSizeofPlane, halfSizeofPlane, 0,
+ halfSizeofPlane, -halfSizeofPlane, 0,
+ halfSizeofPlane, halfSizeofPlane, 0,
+ /* Left face */
+ /* Bottom left */
+ -halfSizeofCube, halfSizeofCube, cubeHeight,
+ -halfSizeofCube, -halfSizeofCube, 0,
+ -halfSizeofCube, -halfSizeofCube, cubeHeight,
+ /* Top right */
+ -halfSizeofCube, halfSizeofCube, cubeHeight,
+ -halfSizeofCube, halfSizeofCube, 0,
+ -halfSizeofCube, -halfSizeofCube, 0,
+ /* Top face */
+ /* Bottom left */
+ -halfSizeofCube, halfSizeofCube, cubeHeight,
+ halfSizeofCube, halfSizeofCube, 0,
+ -halfSizeofCube, halfSizeofCube, 0,
+ /* Top right */
+ -halfSizeofCube, halfSizeofCube, cubeHeight,
+ halfSizeofCube, halfSizeofCube, cubeHeight,
+ halfSizeofCube, halfSizeofCube, 0,
+ /* Right face */
+ /* Bottom left */
+ halfSizeofCube, halfSizeofCube, 0,
+ halfSizeofCube, -halfSizeofCube, cubeHeight,
+ halfSizeofCube, -halfSizeofCube, 0,
+ /* Top right */
+ halfSizeofCube, halfSizeofCube, 0,
+ halfSizeofCube, halfSizeofCube, cubeHeight,
+ halfSizeofCube, -halfSizeofCube, cubeHeight,
+ /* Back face */
+ /* Bottom left */
+ halfSizeofCube, halfSizeofCube, cubeHeight,
+ -halfSizeofCube, -halfSizeofCube, cubeHeight,
+ halfSizeofCube, -halfSizeofCube, cubeHeight,
+ /* Top right */
+ halfSizeofCube, halfSizeofCube, cubeHeight,
+ -halfSizeofCube, halfSizeofCube, cubeHeight,
+ -halfSizeofCube, -halfSizeofCube, cubeHeight,
+ /* Bottom face */
+ /* Bottom left */
+ -halfSizeofCube, -halfSizeofCube, 0,
+ halfSizeofCube, -halfSizeofCube, cubeHeight,
+ -halfSizeofCube, -halfSizeofCube, cubeHeight,
+ /* Top right */
+ -halfSizeofCube, -halfSizeofCube, 0,
+ halfSizeofCube, -halfSizeofCube, 0,
+ halfSizeofCube, -halfSizeofCube, cubeHeight,
+};
+
+
+const float aTexCoords[] =
+{
+ /* Front face. */
+ /* Bottom left */
+ 0.0, 1.0,
+ 0.0, 0.0,
+ 1.0, 0.0,
+ /* Top right */
+ 0.0, 1.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+ /* Left face */
+ /* Bottom left */
+ 1.0, 1.0,
+ 0.0, 0.0,
+ 0.0, 1.0,
+ /* Top right */
+ 1.0, 1.0,
+ 1.0, 0.0,
+ 0.0, 0.0,
+ /* Top face */
+ /* Bottom left */
+ 0.0, 1.0,
+ 1.0, 0.0,
+ 0.0, 0.0,
+ /* Top right */
+ 0.0, 1.0,
+ 1.0, 1.0,
+ 1.0, 0.0,
+ /* Right face */
+ /* Bottom left */
+ 1.0, 0.0,
+ 0.0, 1.0,
+ 0.0, 0.0,
+ /* Top right */
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 0.0, 1.0,
+ /* Back face */
+ /* Bottom left */
+ 1.0, 1.0,
+ 0.0, 0.0,
+ 1.0, 0.0,
+ /* Top right */
+ 1.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 0.0,
+ /* Bottom face */
+ /* Bottom left */
+ 0.0, 0.0,
+ 1.0, 1.0,
+ 0.0, 1.0,
+ /* Top right */
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0
+};
+
+const float aColours[] =
+{
+ /* Front face */
+ /* Bottom left */
+ 0.6f, -0.5f, 0.5f,
+ 0.6f, -0.5f, 0.5f,
+ 0.6f, -0.5f, 0.5f,
+ /* Top right */
+ 0.6f, -0.5f, 0.5f,
+ 0.6f, -0.5f, 0.5f,
+ 0.6f, -0.5f, 0.5f,
+ /* Left face */
+ /* Bottom left */
+ 0.7f, -0.5f, 0.5f,
+ 0.7f, -0.5f, 0.5f,
+ 0.7f, -0.5f, 0.5f,
+ /* Top right */
+ 0.7f, -0.5f, 0.5f,
+ 0.7f, -0.5f, 0.5f,
+ 0.7f, -0.5f, 0.5f,
+ /* Top face */
+ /* Bottom left */
+ 1.f, -0.5f, 0.5f,
+ 1.f, -0.5f, 0.5f,
+ 1.f, -0.5f, 0.5f,
+ /* Top right */
+ 1.f, -0.5f, 0.5f,
+ 1.f, -0.5f, 0.5f,
+ 1.f, -0.5f, 0.5f,
+ /* Right face */
+ /* Bottom left */
+ 0.8f, -0.5f, 0.5f,
+ 0.8f, -0.5f, 0.5f,
+ 0.8f, -0.5f, 0.5f,
+ /* Top right */
+ 0.8f, -0.5f, 0.5f,
+ 0.8f, -0.5f, 0.5f,
+ 0.8f, -0.5f, 0.5f,
+ /* Back face */
+ /* Bottom left */
+ 0.9f, -0.5f, 0.5f,
+ 0.9f, -0.5f, 0.5f,
+ 0.9f, -0.5f, 0.5f,
+ /* Top right */
+ 0.9f, -0.5f, 0.5f,
+ 0.9f, -0.5f, 0.5f,
+ 0.9f, -0.5f, 0.5f,
+ /* Bottom face */
+ /* Bottom left */
+ 1.f, -0.5f, 0.5f,
+ 1.f, -0.5f, 0.5f,
+ 1.f, -0.5f, 0.5f,
+ /* Top right */
+ 1.f, -0.5f, 0.5f,
+ 1.f, -0.5f, 0.5f,
+ 1.f, -0.5f, 0.5f,
+};
+
+float colorList[3][36*3];
+
+
+#endif /* CUBES_H_ */
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#ifndef _GLTOOLS_H_
+#define _GLTOOLS_H_
+
+
+#include <FGraphics.h>
+#include <FUi.h>
+#include <FGraphicsOpengl2.h>
+
+class GLtools
+{
+
+private:
+ GLtools();
+ GLtools(const GLtools&);
+ GLtools& operator=(const GLtools&);
+ ~GLtools();
+
+
+public:
+
+ static bool initGL(Tizen::Ui::Container *const);
+ static void destroyGL();
+ static bool startDrawing();
+ static void finishDrawing();
+ static Tizen::Ui::Container* getCurrentGLContainer();
+ static int getWidth();
+ static int getHeight();
+
+private:
+ static bool initEGL();
+
+
+private:
+ static Tizen::Graphics::Opengl::EGLDisplay eglDisplay;
+ static Tizen::Graphics::Opengl::EGLSurface eglSurface;
+ static Tizen::Graphics::Opengl::EGLConfig eglConfig;
+ static Tizen::Graphics::Opengl::EGLContext eglContext;
+ static Tizen::Ui::Container* pContainer;
+ static int x, y, screenWidth, screenHeight;
+
+};
+
+#endif // __GLTOOLS_H__
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+
+#ifndef _PANELBUTTON_H_
+#define _PANELBUTTON_H_
+
+#include <FBase.h>
+#include <FUi.h>
+
+#include "Tracker.h"
+
+class PanelButton
+ : public Tizen::Ui::Controls::Panel
+{
+public:
+ PanelButton(void);
+ virtual ~PanelButton(void);
+ bool Initialize(Tizen::Ui::IActionEventListener*);
+ result OnInitializing(void);
+ result OnTerminating(void);
+
+ static const int ID_BUTTON_EXECUTE = 503;
+ static const int ID_BUTTON_EXIT = 504;
+ static const int ID_BUTTON_HIDE = 505;
+
+private:
+ Tizen::Ui::IActionEventListener* __pButtonListener;
+};
+
+#endif // _PANELBUTTON_H_
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#ifndef _QR_CODE_RECOGNIZER_SAMPLE_H_
+#define _QR_CODE_RECOGNIZER_SAMPLE_H_
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FSystem.h>
+#include <FUi.h>
+#include <FMedia.h>
+
+#include "TouchForm.h"
+#include "Tracker.h"
+#include "PanelButton.h"
+#include "ControlManager.h"
+
+
+class QrCodeRecognizer
+ : public Tizen::App::UiApp
+ , public Tizen::System::IScreenEventListener
+ , public Tizen::Ui::IActionEventListener
+{
+public:
+ static Tizen::App::Application* CreateInstance(void);
+
+public:
+ QrCodeRecognizer();
+ virtual ~QrCodeRecognizer();
+
+public:
+ // Called when the UiApp is initializing.
+ bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
+
+ // Called when the UiApp initializing is finished.
+ bool OnAppInitialized(void);
+
+ // Called when the UiApp is requested to terminate.
+ bool OnAppWillTerminate(void);
+
+ // Called when the UiApp is terminating.
+ bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
+
+ // Called when the UiApp's frame moves to the top of the screen.
+ void OnForeground(void);
+
+ // Called when this UiApp's frame is moved from top of the screen to the background.
+ void OnBackground(void);
+
+ // Called when the system memory is not sufficient to run the UiApp any further.
+ void OnLowMemory(void);
+
+ // Called when the battery level changes.
+ void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
+
+ // Called when the screen turns on.
+ void OnScreenOn(void);
+
+ // Called when the screen turns off.
+ void OnScreenOff(void);
+
+ virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+
+private:
+
+ void ExecuteQr(Tizen::Base::String);
+
+ Tracker* __pTracker;
+ TouchForm* __pForm;
+ PanelButton* __pPanel;
+ ControlManager* __pControlManager;
+ Tizen::Ui::Controls::Popup* __pPopup;
+
+ static const int ID_BUTTON_YES = 200;
+ static const int ID_BUTTON_NO = 201;
+};
+
+#endif // _QR_CODE_RECOGNIZER_SAMPLE_H_
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+
+#ifndef RENDERER_H_
+#define RENDERER_H_
+
+#include <FGraphics.h>
+#include <FUi.h>
+#include <FGraphicsOpengl2.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+using namespace Tizen::Graphics::Opengl;
+
+#define CUBE_COUNT 16
+
+class Renderer
+{
+public:
+ Renderer();
+ ~Renderer();
+
+ void Init(int width, int height);
+ void SetTextureData( int width, int height, void* data );
+ void SetModelViewMatrix( int i, const Tizen::Graphics::FloatMatrix4* );
+ void SetCameraAngle( float angle );
+ void Draw();
+ void Update(float t);
+
+private:
+
+ /// Load a shader, check for compile errors, print error messages to output log
+ GLuint loadShader(GLenum type, const char *shaderSrc);
+
+ /// Load a vertex and fragment shader, create a program object, link program. Errors output to log.
+ GLuint loadProgram(const char *vertShaderSrc, const char *fragShaderSrc);
+
+ GLuint createSimpleTexture2D(GLenum type, int width, int height);
+
+ /// Simulates desktop's glRotatef. The matrix is returned in column-major order.
+ void rotateMatrix(double angle, double x, double y, double z, float *R);
+
+ /// Simulates gluPerspectiveMatrix
+ void perspectiveMatrix(double fovy, double aspect, double znear, double zfar, float *P);
+
+ /// Multiplies A by B and writes out to C. All matrices are 4x4 and column major. In-place multiplication is supported.
+ void multiplyMatrix(const float *A, const float *B, float *C);
+
+ GLuint __programObject;
+
+ // Attribute locations
+ GLint __positionLoc;
+ GLint __texCoordLoc;
+ GLint __colorLoc;
+ GLint __mvpPLoc;
+
+ // Sampler location
+ GLint __samplerLoc;
+ GLint __samplerColorLoc;
+
+ // Texture handle
+ GLuint __textureId;
+ GLuint __textureColorId;
+
+ float __modelView[CUBE_COUNT][16];
+ float __perspectiveMatrix[16];
+ float __mvp2[16];
+ float __cameraAngle;
+
+};
+
+#endif // RENDERER_H_
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#ifndef _TOUCHFORM_H_
+#define _TOUCHFORM_H_
+
+#include <FBase.h>
+#include <FUi.h>
+#include "PanelButton.h"
+
+class TouchForm
+ : public Tizen::Ui::Controls::Form
+ , public Tizen::Ui::ITouchEventListener
+{
+public:
+
+ TouchForm(void);
+ virtual ~TouchForm(void);
+ bool Initialize(void);
+
+public:
+
+ virtual result OnInitializing(void);
+ virtual result OnTerminating(void);
+
+ virtual void OnTouchLongPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
+ virtual void OnTouchMoved(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
+ virtual void OnTouchPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
+ virtual void OnTouchReleased(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
+ virtual void OnTouchDoublePressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
+ virtual void OnTouchFocusIn(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
+ virtual void OnTouchFocusOut(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
+
+ virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs);
+
+ static const RequestId REQUEST_EXIT = 555;
+ static const RequestId REQUEST_SHOW_TEXT = 55;
+ static const RequestId REQUEST_ACTIVATE = 100;
+ static const RequestId REQUEST_DEACTIVATE = 101;
+
+private:
+ void Activate(void);
+ void Deactivate(void);
+
+ PanelButton* __pPanel;
+};
+
+#endif // _TOUCHFORM_H_
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#ifndef _TRACKER_H_
+#define _TRACKER_H_
+
+#include <FBase.h>
+#include <FMedia.h>
+#include <FUixVisionQrCodeRecognizer.h>
+
+#include "GLtools.h"
+#include "Renderer.h"
+
+
+class Tracker
+ : public Tizen::Media::ICameraEventListener
+{
+public:
+ Tracker(void);
+ virtual ~Tracker(void);
+
+ void Init(Tizen::Ui::Controls::Form*);
+ void DoRendering(bool);
+ Tizen::Base::String GetTextMessage(void);
+ void Terminate(void);
+
+ // Called when camera auto focus occurred
+ void OnCameraAutoFocused(bool completeCondition);
+
+ // Called when camera preview occurred
+ void OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r);
+
+ // Called when camera captured image
+ void OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData, result r);
+
+ // Called when camera error occurred
+ void OnCameraErrorOccurred(Tizen::Media::CameraErrorReason r);
+
+ static const int DESIRED_CAMERA_WIDTH = 640;
+ static const int DESIRED_CAMERA_HEIGHT = 480;
+
+private:
+ void InitRecognizer(void);
+ void Focus(bool);
+
+private:
+ Tizen::Uix::Vision::QrCodeRecognizer* __pQrRecognizer;
+ Renderer* __pRenderer;
+ Tizen::Graphics::Rectangle* __pRoi;
+ Tizen::Ui::Controls::Label* __pLabel;
+ Tizen::Base::String __qrText;
+ Tizen::Ui::Controls::Form* __pForm;
+
+ bool __doRender;
+ bool __terminating;
+};
+
+#endif
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest">
+ <Id>$(manifestAppId)</Id>
+ <Version>1.0.0</Version>
+ <Type>C++App</Type>
+ <Author/>
+ <Descriptions/>
+ <Requirements>
+ <Feature Name="http://tizen.org/feature/platform.core.cpu.arch">x86</Feature>
+ <Feature Name="http://tizen.org/feature/platform.core.fpu.arch">vfpv3</Feature>
+ <Feature Name="http://tizen.org/feature/screen.coordinate_system.logical">Normal</Feature>
+ </Requirements>
+ <Apps>
+ <ApiVersion>2.1</ApiVersion>
+ <Privileges>
+ <Privilege>http://tizen.org/privilege/application.launch</Privilege>
+ <Privilege>http://tizen.org/privilege/camera</Privilege>
+ <Privilege>http://tizen.org/privilege/power</Privilege>
+ </Privileges>
+ <UiApp HwAcceleration="On" Main="True" MenuIconVisible="True" Name="$(projectName)">
+ <UiScalability BaseScreenSize="Normal" CoordinateSystem="Logical" LogicalCoordinate="720"/>
+ <UiTheme SystemTheme="White"/>
+ <DisplayNames>
+ <DisplayName Locale="eng-GB">$(projectName)</DisplayName>
+ </DisplayNames>
+ <Icons>
+ <Icon Section="MainMenu" Type="Xhigh">mainmenu.png</Icon>
+ </Icons>
+ <LaunchConditions/>
+ <Notifications/>
+ </UiApp>
+ </Apps>
+</Manifest>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<!DOCTYPE ScenePanel SYSTEM "UIForm.dtd">
+<ScenePanel Bversion="3.0.0.201302011734" Dversion="20120315">
+ <Panel id="IDC_BUTTON_PANEL">
+ <property backgroundColor="" backgroundColorOpacity="0" compositeEnabled="true" groupStyle="GROUP_STYLE_NONE"/>
+ <layout height="720" mode="Portrait" type="LAYOUT_VERTICAL_BOX" verticalDirection="VERTICAL_DIRECTION_DOWNWARD" width="800" x="0" y="0"/>
+ <layout height="720" mode="Landscape" type="LAYOUT_VERTICAL_BOX" verticalDirection="VERTICAL_DIRECTION_DOWNWARD" width="300" x="0" y="0"/>
+ </Panel>
+</ScenePanel>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<!DOCTYPE Scene SYSTEM "UIForm.dtd">
+<Scene Bversion="2.0.0.201302151552" Dversion="20120315">
+ <LogicalCoordinate>720</LogicalCoordinate>
+ <Form id="IDF_FORM">
+ <property backgroundColor="" backgroundColorOpacity="100" orientation="Landscape" softKey0NormalIcon="" softKey0PressedIcon="" softKey0Text="" softKey1NormalIcon="" softKey1PressedIcon="" softKey1Text="" title="" titleAlign="ALIGN_LEFT" titleIcon="" translucentFooter="false" translucentHeader="false" translucentIndicator="false"/>
+ <layout mode="Landscape" style="FORM_STYLE_NORMAL" type="LAYOUT_RELATIVE"/>
+ </Form>
+ <Label id="IDC_INFO_LABEL" parent="IDF_FORM">
+ <property backgroundBitmapPath="" backgroundColor="" backgroundColorOpacity="0" horizontalAlign="ALIGN_LEFT" text="" textColor="Blue" textSize="33" textStyle="LABEL_TEXT_STYLE_NORMAL" verticalAlign="ALIGN_TOP"/>
+ <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="500" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="IDF_FORM" leftRelationType="RECT_EDGE_RELATION_LEFT_TO_LEFT" marginBottom="0" marginLeft="20" marginRight="0" marginTop="20" mode="Landscape" rightRelation="" rightRelationType="" topRelation="IDF_FORM" topRelationType="RECT_EDGE_RELATION_TOP_TO_TOP" verticalFitPolicy="FIT_POLICY_FIXED" width="1237" x="20" y="20"/>
+ <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="165" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0" marginLeft="0" marginRight="0" marginTop="0" mode="Portrait" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="168" x="20" y="65"/>
+ </Label>
+</Scene>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<!DOCTYPE ScenePopup SYSTEM "UIForm.dtd">
+<ScenePopup Bversion="3.0.0.201301081740" Dversion="20120315">
+ <Popup id="ID_POPUP">
+ <property color="" titleText=" " titleTextColor=""/>
+ <layout height="517" mode="Portrait" style="" type="LAYOUT_RELATIVE" width="678"/>
+ <layout height="576" mode="Landscape" style="" type="LAYOUT_RELATIVE" width="430"/>
+ </Popup>
+ <Button id="IDC_BUTTON_YES" parent="ID_POPUP">
+ <property disableTextColor="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="YES" textSize="33" verticalAlign="ALIGN_MIDDLE"/>
+ <layout bottomRelation="ID_POPUP" bottomRelationType="RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM" centerHorizontal="false" centerVertical="false" height="80" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="ID_POPUP" leftRelationType="RECT_EDGE_RELATION_LEFT_TO_LEFT" marginBottom="50" marginLeft="100" marginRight="0" marginTop="0" mode="Portrait" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="150" x="100" y="307"/>
+ <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="106" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0" marginLeft="0" marginRight="0" marginTop="0" mode="Landscape" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="79" x="33" y="363"/>
+ </Button>
+ <Button id="IDC_BUTTON_NO" parent="ID_POPUP">
+ <property disableTextColor="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="NO" textSize="33" verticalAlign="ALIGN_MIDDLE"/>
+ <layout bottomRelation="ID_POPUP" bottomRelationType="RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM" centerHorizontal="false" centerVertical="false" height="80" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="50" marginLeft="0" marginRight="100" marginTop="0" mode="Portrait" rightRelation="ID_POPUP" rightRelationType="RECT_EDGE_RELATION_RIGHT_TO_RIGHT" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="150" x="388" y="307"/>
+ <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="106" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0" marginLeft="0" marginRight="0" marginTop="0" mode="Landscape" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="100" x="196" y="361"/>
+ </Button>
+ <TextBox id="IDC_TEXTBOX" parent="ID_POPUP">
+ <property disabledBackgroundBitmapPath="" disabledColor="" disabledColorOpacity="100" disabledTextColor="" highlightedBackgroundBitmapPath="" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" lineSpacingExtra="1" lineSpacingMultiplier="1" normalBackgroundBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" text="" textAlignment="" textSize="45" textboxBorder="TEXT_BOX_BORDER_ROUNDED"/>
+ <layout bottomRelation="IDC_BUTTON_YES" bottomRelationType="RECT_EDGE_RELATION_BOTTOM_TO_TOP" centerHorizontal="true" centerVertical="false" height="267" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="20" marginLeft="0" marginRight="0" marginTop="100" mode="Portrait" rightRelation="" rightRelationType="" topRelation="ID_POPUP" topRelationType="RECT_EDGE_RELATION_TOP_TO_TOP" verticalFitPolicy="FIT_POLICY_FIXED" width="455" x="91" y="20"/>
+ <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="200" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0" marginLeft="0" marginRight="0" marginTop="0" mode="Landscape" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="241" x="148" y="295"/>
+ </TextBox>
+</ScenePopup>
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#include "CameraTools.h"
+
+Tizen::Media::Camera* CameraTools::__pCamera(null);
+Tizen::Graphics::Dimension CameraTools::__choosenResolution;
+int CameraTools::__width;
+int CameraTools::__height;
+
+bool
+CameraTools::StartCamera(Tizen::Media::ICameraEventListener &listener,
+ const unsigned int width, const unsigned int height)
+{
+
+ __choosenResolution = Tizen::Graphics::Dimension(width, height);
+
+ if (__pCamera)
+ {
+ return true;
+ }
+
+ __pCamera = new Tizen::Media::Camera();
+ if (null == __pCamera)
+ {
+ return false;
+ }
+
+ if (IsFailed(__pCamera->Construct(listener, Tizen::Media::CAMERA_PRIMARY)))
+ {
+ return false;
+ }
+
+ if (IsFailed(__pCamera->PowerOn()))
+ {
+ return false;
+ }
+
+ if (IsFailed(__pCamera->SetPreviewFormat(Tizen::Graphics::PIXEL_FORMAT_YCbCr420_PLANAR)))
+ {
+ return false;
+ }
+
+ if (IsFailed(__pCamera->SetPreviewFrameRate(30)))
+ {
+ return false;
+ }
+
+ Tizen::Base::Collection::IList* _pList = __pCamera->GetSupportedPreviewResolutionListN();
+
+ if(_pList)
+ {
+ int _count = _pList->GetCount();
+ if (_count)
+ {
+ Tizen::Base::Collection::IEnumerator* _pEnum = _pList->GetEnumeratorN();
+ if (_pEnum)
+ {
+ result _res = E_SUCCESS;
+ int _area; //area of camera preview image
+
+ while (E_SUCCESS == _res)
+ {
+ _res = _pEnum->MoveNext();
+ switch (_res)
+ {
+ case E_SUCCESS:
+ {
+ Tizen::Graphics::Dimension* _pSupportedDim = (Tizen::Graphics::Dimension*) _pEnum->GetCurrent();
+ if (_pSupportedDim)
+ {
+ if (_pSupportedDim->width <= width && _pSupportedDim->height <= height)
+ {
+ int _supportedArea = _pSupportedDim->width * _pSupportedDim->height;
+ if (_supportedArea > _area)
+ {
+ __choosenResolution = *_pSupportedDim;
+ _area = _supportedArea;
+ }
+ }
+ }
+ break;
+ }
+ case E_OUT_OF_RANGE:
+ break;
+ case E_INVALID_OPERATION:
+ default:
+ break;
+ }
+ }
+
+ delete _pEnum;
+ }
+
+ }
+ delete _pList;
+ }
+
+ if (IsFailed(__pCamera->SetPreviewResolution(__choosenResolution)))
+ {
+ return false;
+ }
+
+ __width = __pCamera->GetPreviewResolution().width;
+ __height = __pCamera->GetPreviewResolution().height;
+
+ return true;
+}
+
+void
+CameraTools::StopCamera(void)
+{
+ if (__pCamera)
+ {
+ __pCamera->PowerOff();
+ delete __pCamera;
+ __pCamera = null;
+ }
+ return;
+}
+
+void
+CameraTools::Suspend(void)
+{
+ if (__pCamera)
+ __pCamera->StopPreview();
+ AppLogExceptionTag("QrCodeRecognizer", "CameraTools::Suspend");
+}
+
+void
+CameraTools::Restart(void)
+{
+ if (__pCamera)
+ __pCamera->StartPreview(null, true);
+ if (IsFailed(__pCamera->SetFocusMode(Tizen::Media::CAMERA_FOCUS_MODE_CONTINUOUS_AUTO)))
+ {
+ return;
+ }
+
+ if (IsFailed(__pCamera->SetAutoFocus(false)))
+ {
+ return;
+ }
+ AppLogExceptionTag("QrCodeRecognizer", "CameraTools::Restart");
+}
+
+void
+CameraTools::ZoomIn(void)
+{
+ if(__pCamera)
+ __pCamera->ZoomIn();
+}
+
+void
+CameraTools::ZoomOut(void)
+{
+ if(__pCamera)
+ __pCamera->ZoomOut();
+}
+
+Tizen::Media::Camera*
+CameraTools::GetCamera(void)
+{
+ return __pCamera;
+}
+
+int
+CameraTools::GetWidth(void)
+{
+ return __width;
+}
+
+int
+CameraTools::GetHeight(void)
+{
+ return __height;
+}
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#include "ControlManager.h"
+#include <FApp.h>
+#include <FUi.h>
+#include <FIo.h>
+#include "TouchForm.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+
+static const String TEMP_VCARD_PATH = L"/opt/media/temp.vcf";
+
+ControlManager::ControlManager()
+ : __provider("")
+ , __operation("")
+{
+ __data.Construct();
+}
+
+ControlManager::~ControlManager()
+{
+}
+
+ControlManager*
+ControlManager::GetInstance()
+{
+ static ControlManager __manager;
+ return &__manager;
+}
+
+
+void
+ControlManager::StartControl(void)
+{
+ AppControl* pAc = AppManager::FindAppControlN(__provider, __operation);
+ if (pAc)
+ {
+ pAc->Start(null, null, &__data, null);
+ delete pAc;
+ }
+ __data.RemoveAll();
+}
+
+void
+ControlManager::ShowText(Tizen::Base::String __text)
+{
+ __provider = L"";
+ __operation = L"";
+ Tizen::Ui::Controls::MessageBox msgBox;
+ msgBox.Construct("Text Recognized", __text, Tizen::Ui::Controls::MSGBOX_STYLE_OK);
+ int modalResult;
+ msgBox.ShowAndWait(modalResult);
+}
+
+void
+ControlManager::ShowUrl(Tizen::Base::String __url)
+{
+
+ __provider = L"tizen.internet";
+ __operation = L"http://tizen.org/appcontrol/operation/view";
+
+ String urlKey("url");
+ String urlVal(__url);
+ __data.Add(&urlKey, &urlVal);
+
+ StartControl();
+}
+
+void
+ControlManager::ShowSms(Tizen::Base::String __numbers, Tizen::Base::String __body)
+{
+ __provider = L"tizen.messages";
+ __operation = L"http://tizen.org/appcontrol/operation/compose";
+
+ String typeKey = L"type";
+ String typeVal = L"SMS";
+ String textKey = L"text";
+ String textVal = __body;
+ String toKey = L"to";
+ String toVal = __numbers;
+ __data.Add(&typeKey, &typeVal);
+ __data.Add(&textKey, &textVal);
+ __data.Add(&toKey, &toVal);
+ StartControl();
+}
+
+void
+ControlManager::ShowContact(Tizen::Base::String __Text)
+{
+ __provider = L"tizen.contacts";
+ __operation = L"http://tizen.org/appcontrol/operation/view";
+
+ String typeKey("viewType");
+ String typeVal("vcf");
+ String pathKey("path");
+ String pathVal(TEMP_VCARD_PATH);
+ __data.Add(&typeKey, &typeVal);
+ __data.Add(&pathKey, &pathVal);
+
+ Tizen::Io::File file;
+ result r = file.Construct(TEMP_VCARD_PATH, L"w+");
+ if (IsFailed(r))
+ {
+ return;
+ }
+
+ r = file.Write(__Text);
+ if (IsFailed(r))
+ {
+ return;
+ }
+
+ r = file.Flush();
+ StartControl();
+}
+
+void
+ControlManager::ShowCall(Tizen::Base::String __phone)
+{
+ __provider = L"tizen.phone";
+ __operation = L"http://tizen.org/appcontrol/operation/call";
+
+ String telKey(L"tel");
+ String telVal(__phone);
+ String typeKey("type");
+ String typeVal("voice");
+ __data.Add(&telKey, &telVal);
+ __data.Add(&typeKey, &typeVal);
+
+ StartControl();
+}
+
+void
+ControlManager::ShowEmail(Tizen::Base::String __addr)
+{
+ __provider = L"tizen.email";
+ __operation = L"http://tizen.org/appcontrol/operation/compose";
+
+ StartControl();
+}
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#include "GLtools.h"
+
+using namespace Tizen::Graphics::Opengl;
+
+EGLDisplay GLtools::eglDisplay(EGL_DEFAULT_DISPLAY);
+EGLSurface GLtools::eglSurface(EGL_NO_SURFACE);
+EGLConfig GLtools::eglConfig(null);
+EGLContext GLtools::eglContext(EGL_NO_DISPLAY);
+Tizen::Ui::Container* GLtools::pContainer(null);
+int GLtools::x(0);
+int GLtools::y(0);
+int GLtools::screenWidth(0);
+int GLtools::screenHeight(0);
+
+
+Tizen::Ui::Container*
+GLtools::getCurrentGLContainer()
+{
+ return pContainer;
+}
+
+bool
+GLtools::initEGL()
+{
+ EGLint numConfigs = 1;
+ EGLint eglConfigList[] = {
+ EGL_RED_SIZE, 5,
+ EGL_GREEN_SIZE, 6,
+ EGL_BLUE_SIZE, 5,
+ EGL_ALPHA_SIZE, 0,
+ EGL_DEPTH_SIZE, 8,
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_NONE
+ };
+ EGLint eglContextList[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
+
+ eglBindAPI(EGL_OPENGL_ES_API);
+
+ if (eglDisplay)
+ {
+ return false;
+ }
+
+ eglDisplay = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY);
+ if (EGL_NO_DISPLAY == eglDisplay)
+ {
+ return false;
+ }
+
+ if (EGL_FALSE == eglInitialize(eglDisplay, null, null) || EGL_SUCCESS != eglGetError())
+ {
+ return false;
+ }
+
+ if (EGL_FALSE == eglChooseConfig(eglDisplay, eglConfigList, &eglConfig, 1, &numConfigs) || EGL_SUCCESS != eglGetError())
+ {
+ return false;
+ }
+
+ if (!numConfigs)
+ {
+ return false;
+ }
+
+ eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, (EGLNativeWindowType) pContainer, null);
+
+ if (EGL_NO_SURFACE == eglSurface || EGL_SUCCESS != eglGetError())
+ {
+ return false;
+ }
+
+ eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, eglContextList);
+ if (EGL_NO_CONTEXT == eglContext || EGL_SUCCESS != eglGetError())
+ {
+ return false;
+ }
+
+ if (EGL_FALSE == eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) || EGL_SUCCESS != eglGetError())
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool
+GLtools::initGL(Tizen::Ui::Container *const container)
+{
+ if(pContainer == container)
+ return true;
+
+ if(pContainer)
+ destroyGL();
+ pContainer = container;
+
+ if (!initEGL())
+ {
+ destroyGL();
+ pContainer = null;
+ x = 0;
+ y = 0;
+ screenWidth = 0;
+ screenHeight = 0;
+ return false;
+ }
+
+ pContainer->GetBounds(x, y, screenWidth, screenHeight);
+
+ return true;
+}
+
+void
+GLtools::destroyGL()
+{
+ if (eglDisplay)
+ {
+ eglMakeCurrent(eglDisplay, null, null, null);
+
+ if (eglContext)
+ {
+ eglDestroyContext(eglDisplay, eglContext);
+ eglContext = EGL_NO_CONTEXT;
+ }
+
+ if (eglSurface)
+ {
+ //eglDestroySurface(eglDisplay, eglSurface);
+ eglSurface = EGL_NO_SURFACE;
+ }
+
+ //eglTerminate(eglDisplay);
+ eglDisplay = EGL_NO_DISPLAY;
+ }
+
+ pContainer = null;
+ return;
+}
+
+bool
+GLtools::startDrawing()
+{
+ if (!pContainer->IsEnabled()) return false;
+
+ if (GL_FALSE == eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) || EGL_SUCCESS != eglGetError()) return false;
+
+ glViewport(x, y, screenWidth, screenHeight);
+
+ glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+ return true;
+}
+
+
+void
+GLtools::finishDrawing(void)
+{
+ //Causing image flickering. 2.1.0_RC12_M5
+ //glFlush();
+ glFinish();
+ eglSwapBuffers(eglDisplay, eglSurface);
+}
+
+int
+GLtools::getWidth(void)
+{
+ return (screenWidth);
+}
+
+int
+GLtools::getHeight(void)
+{
+ return (screenHeight);
+}
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#include <FApp.h>
+#include "PanelButton.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+
+
+PanelButton::PanelButton(void)
+ : __pButtonListener(0)
+{
+}
+
+PanelButton::~PanelButton(void)
+{
+}
+
+bool
+PanelButton::Initialize(Tizen::Ui::IActionEventListener* listener)
+{
+ Panel::Construct("IDC_BUTTON_PANEL");
+ __pButtonListener = listener;
+ return true;
+}
+
+result
+PanelButton::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+
+ Button *pButtonExecute = new Button();
+ pButtonExecute->Construct(Tizen::Graphics::Rectangle(0, 0, this->GetWidth(), this->GetHeight() / 3), "Process QR");
+ pButtonExecute->SetActionId(ID_BUTTON_EXECUTE);
+ pButtonExecute->AddActionEventListener(*__pButtonListener);
+ this->AddControl(*pButtonExecute);
+
+ Button *pButtonExit = new Button();
+ pButtonExit->Construct(Tizen::Graphics::Rectangle(0, 0, this->GetWidth(), this->GetHeight() / 3), "Exit");
+ pButtonExit->SetActionId(ID_BUTTON_EXIT);
+ pButtonExit->AddActionEventListener(*__pButtonListener);
+ this->AddControl(*pButtonExit);
+
+ Button *pButtonHide = new Button();
+ pButtonHide->Construct(Tizen::Graphics::Rectangle(0, 0, this->GetWidth(), this->GetHeight() / 3), "Hide");
+ pButtonHide->SetActionId(ID_BUTTON_HIDE);
+ pButtonHide->AddActionEventListener(*__pButtonListener);
+ this->AddControl(*pButtonHide);
+
+ return r;
+}
+
+result
+PanelButton::OnTerminating(void)
+{
+ result r = E_SUCCESS;
+ return r;
+}
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#include "QrCodeRecognizerSample.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // __cplusplus
+
+_EXPORT_ int OspMain(int argc, char *pArgv[]);
+
+/**
+ * The entry function of Tizen application called by the operating system.
+ */
+int
+OspMain(int argc, char *pArgv[])
+{
+ result r = E_SUCCESS;
+
+ ArrayList* pArgs = new ArrayList();
+ pArgs->Construct();
+ for (int i = 0; i < argc; i++)
+ {
+ pArgs->Add(*(new String(pArgv[i])));
+ }
+
+ r = Tizen::App::UiApp::Execute(QrCodeRecognizer::CreateInstance, pArgs);
+ if (IsFailed(r))
+ {
+ AppLogException("Application execution failed-[%s].", GetErrorMessage(r));
+ r &= 0x0000FFFF;
+ }
+
+ pArgs->RemoveAll(true);
+ delete pArgs;
+
+ return static_cast<int>(r);
+}
+#ifdef __cplusplus
+}
+#endif // __cplusplus
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#include "QrCodeRecognizerSample.h"
+#include "CameraTools.h"
+#include "GLtools.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::System;
+
+QrCodeRecognizer::QrCodeRecognizer()
+ : __pTracker(0)
+ , __pForm(0)
+ , __pPanel(0)
+ , __pControlManager(0)
+ , __pPopup(0)
+{
+}
+
+QrCodeRecognizer::~QrCodeRecognizer()
+{
+}
+
+
+UiApp*
+QrCodeRecognizer::CreateInstance(void)
+{
+ // Create the instance through the constructor.
+ return new QrCodeRecognizer();
+}
+
+
+bool
+QrCodeRecognizer::OnAppInitializing(AppRegistry& appRegistry)
+{
+ PowerManager::SetScreenEventListener(*this);
+ PowerManager::KeepScreenOnState(true, false);
+ return true;
+}
+
+bool
+QrCodeRecognizer::OnAppInitialized(void)
+{
+ Frame* pAppFrame = new Frame();
+ pAppFrame->Construct();
+ AddFrame(*pAppFrame);
+
+ pAppFrame->SetOrientation(Tizen::Ui::ORIENTATION_LANDSCAPE);
+
+ // Creates an instance of Popup
+ __pPopup = new Tizen::Ui::Controls::Popup();
+ __pPopup->Construct(true, Tizen::Graphics::Dimension(570, 250));
+ __pPopup->SetTitleText(L"Exit application?");
+
+ // Creates an instance of Button to close the popup.
+ Button* pYesButton = new Button();
+ pYesButton->Construct(Tizen::Graphics::Rectangle(10, 50, 250, 80), L"Yes");
+ pYesButton->SetActionId(ID_BUTTON_YES);
+ pYesButton->AddActionEventListener(*this);
+
+ Button* pNoButton = new Button();
+ pNoButton->Construct(Tizen::Graphics::Rectangle(270, 50, 250, 80), L"No");
+ pNoButton->SetActionId(ID_BUTTON_NO);
+ pNoButton->AddActionEventListener(*this);
+
+ // Adds the button to the popup
+ __pPopup->AddControl(*pYesButton);
+ __pPopup->AddControl(*pNoButton);
+
+ __pPanel = new PanelButton();
+ __pPanel->Initialize(this);
+ __pPanel->SetBounds(pAppFrame->GetHeight() - pAppFrame->GetHeight() / 5, 0, pAppFrame->GetHeight() / 5, pAppFrame->GetWidth());
+
+ __pForm = new TouchForm();
+ __pForm->Initialize();
+ __pForm->AddControl(*__pPanel);
+ pAppFrame->AddControl(*__pForm);
+
+ GLtools::initGL(__pForm);
+
+ __pTracker = new Tracker();
+ CameraTools::StartCamera(*__pTracker, Tracker::DESIRED_CAMERA_WIDTH, Tracker::DESIRED_CAMERA_HEIGHT);
+
+ __pTracker->Init(__pForm);
+ CameraTools::Restart();
+
+ __pForm->SendUserEvent(TouchForm::REQUEST_ACTIVATE, null);
+
+ return true;
+}
+
+bool
+QrCodeRecognizer::OnAppWillTerminate(void)
+{
+ return true;
+}
+
+bool
+QrCodeRecognizer::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+ __pTracker->DoRendering(false);
+ CameraTools::StopCamera();
+ GLtools::destroyGL();
+
+ delete __pTracker;
+ return true;
+}
+
+void
+QrCodeRecognizer::OnForeground(void)
+{
+ PowerManager::KeepScreenOnState(true, false);
+ CameraTools::Restart();
+}
+
+// Called when application is moved to background
+void
+QrCodeRecognizer::OnBackground(void)
+{
+ CameraTools::Suspend();
+}
+
+void
+QrCodeRecognizer::OnLowMemory(void)
+{
+}
+
+void
+QrCodeRecognizer::OnBatteryLevelChanged(BatteryLevel batteryLevel)
+{
+}
+
+void
+QrCodeRecognizer::OnScreenOn (void)
+{
+ PowerManager::KeepScreenOnState(true, false);
+ CameraTools::Restart();
+}
+
+void
+QrCodeRecognizer::OnScreenOff (void)
+{
+ CameraTools::Suspend();
+}
+
+void
+QrCodeRecognizer::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+ switch(actionId)
+ {
+ case PanelButton::ID_BUTTON_HIDE:
+ {
+ __pPanel->SetEnabled(false);
+ __pPanel->SetShowState(false);
+ }
+ break;
+ case PanelButton::ID_BUTTON_EXIT:
+ {
+// __pPopup->SetShowState(true);
+ __pTracker->Terminate();
+// __pPopup->Show();
+ }
+ break;
+ case PanelButton::ID_BUTTON_EXECUTE:
+ ExecuteQr(__pTracker->GetTextMessage());
+ break;
+
+ case ID_BUTTON_YES:
+ //Crushing application without this
+ delete __pPopup;
+ __pTracker->Terminate();
+ break;
+ case ID_BUTTON_NO:
+ __pPopup->SetShowState(false);
+ break;
+ default:
+ break;
+ }
+}
+
+void
+QrCodeRecognizer::ExecuteQr(Tizen::Base::String text)
+{
+ if (!text.IsEmpty())
+ {
+ ControlManager* cMan = ControlManager::GetInstance();
+
+ if (text.StartsWith(L"http://", 0) ||
+ text.StartsWith("ftp://", 0) ||
+ text.StartsWith("ftps://", 0) ||
+ text.StartsWith("sftp://", 0) ||
+ text.StartsWith("https://", 0)
+ )
+ {
+ cMan->ShowUrl(text);
+ }
+ else if (text.StartsWith(L"sms:", 0))
+ {
+ Tizen::Base::String _number;
+ Tizen::Base::String _body;
+
+ int _numberStartIndex = 4; // message starting with "sms:" substring with length = 4
+ int _numberFinishIndex;
+ int _messageStartIndex;
+ text.IndexOf(L"?", _numberStartIndex, _numberFinishIndex);
+ text.SubString(_numberStartIndex, _numberFinishIndex - _numberStartIndex, _number);
+ text.IndexOf(L"body=", _numberStartIndex, _messageStartIndex);
+ text.SubString(_messageStartIndex + 5, _body);
+
+ cMan->ShowSms(_number, _body);
+ }
+ else if (text.StartsWith(L"BEGIN:VCARD", 0))
+ {
+ cMan->ShowContact(text);
+ }
+ else
+ {
+ cMan->ShowText(text);
+ }
+ }
+}
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#include "Renderer.h"
+
+#include "CameraTools.h"
+#include "GLtools.h"
+#include "Cubes.h"
+
+using namespace Tizen::Graphics::Opengl;
+
+Renderer::Renderer()
+{
+}
+
+Renderer::~Renderer()
+{
+}
+
+void
+Renderer::SetTextureData(int width, int height, void* data)
+{
+ glBindTexture (GL_TEXTURE_2D, __textureColorId);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width >> 1, height >> 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, ((unsigned char*) data) + width * height);
+ glBindTexture (GL_TEXTURE_2D, __textureId);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
+}
+
+void
+Renderer::SetModelViewMatrix(int i, const Tizen::Graphics::FloatMatrix4* mat)
+{
+ if (mat)
+ memcpy(__modelView[i], mat->matrix, 16 * sizeof(float));
+
+ float matrix[16] = {0.f};
+ multiplyMatrix(leftTransform, __modelView[i], matrix);
+ multiplyMatrix(matrix, rightTransform, __modelView[i]);
+}
+
+void
+Renderer::SetCameraAngle(float angle)
+{
+ __cameraAngle = angle;
+}
+
+void
+Renderer::Init(int width, int height)
+{
+ GLbyte vShaderStr[] =
+ "attribute vec4 a_Position; \n"
+ "attribute vec2 a_TexCoord; \n"
+ "attribute vec3 a_Colour; \n"
+ " \n"
+ "uniform mat4 u_Mvp; \n"
+ " \n"
+ "varying vec2 v_TexCoord; \n"
+ "varying vec3 v_Colour; \n"
+ " \n"
+ "void main() \n"
+ "{ \n"
+ " gl_Position = u_Mvp * a_Position; \n"
+ " v_TexCoord = a_TexCoord; \n"
+ " v_Colour = a_Colour; \n"
+ "} \n";
+
+ GLbyte fShaderStr[] =
+ "precision mediump float; \n"
+ "uniform sampler2D s_Texture; \n"
+ "uniform sampler2D s_TextureColor; \n"
+ "varying vec2 v_TexCoord; \n"
+ "varying vec3 v_Colour; \n"
+ " \n"
+ "void main() \n"
+ "{ \n"
+ " float y = texture2D(s_Texture, v_TexCoord).r + v_Colour.r; \n"
+ " float v = texture2D(s_TextureColor, vec2(v_TexCoord.x, v_TexCoord.y) * 0.5).r + v_Colour.b - 0.5;\n"
+ " float u = texture2D(s_TextureColor, vec2(v_TexCoord.x, v_TexCoord.y + 1.0) * 0.5).a + v_Colour.g - 0.5;\n"
+ " float r = y + 1.772 * u; \n"
+ " float g = y - 0.34414 * u - 0.71414 * v; \n"
+ " float b = y + 1.402 * v; \n"
+ " gl_FragColor = vec4(r, g, b, 1.0); \n"
+ "} \n";
+
+ // Load the shaders and get a linked program object
+ __programObject = loadProgram ((char *)vShaderStr, (char *)fShaderStr);
+
+ // Get the attribute locations
+ __positionLoc = glGetAttribLocation (__programObject, "a_Position");
+ __texCoordLoc = glGetAttribLocation (__programObject, "a_TexCoord");
+ __colorLoc = glGetAttribLocation (__programObject, "a_Colour");
+
+ // Get the sampler location
+ __samplerLoc = glGetUniformLocation (__programObject, "s_Texture");
+ __samplerColorLoc = glGetUniformLocation (__programObject, "s_TextureColor");
+ __mvpPLoc = glGetUniformLocation (__programObject, "u_Mvp");
+
+ // Load the texture
+ __textureId = createSimpleTexture2D (GL_LUMINANCE, width, height);
+ __textureColorId = createSimpleTexture2D (GL_LUMINANCE_ALPHA, width >> 1, height >> 1);
+
+ __mvp2[0] = 1; __mvp2[1] = 0; __mvp2[2] = 0; __mvp2[3] = 0;
+ __mvp2[4] = 0; __mvp2[5] = 1; __mvp2[6] = 0; __mvp2[7] = 0;
+ __mvp2[8] = 0; __mvp2[9] = 0; __mvp2[10] = 1; __mvp2[11] = 0;
+ __mvp2[12] = 0; __mvp2[13] = 0; __mvp2[14] = 0; __mvp2[15] = 1;
+
+ for(int i = 0; i < CUBE_COUNT; ++i)
+ {
+ memset(__modelView[i], 0, 16 * sizeof(float));
+ }
+
+ float u[] = {0.f, 0.25f, 0.f};
+ float v[] = {0.f, 0.f, 0.25f};
+ for(int j = 0; j < 3; ++j)
+ {
+ for(int i = 0; i < 36; ++i)
+ {
+ colorList[j][i * 3] = aColours[i * 3];
+ colorList[j][i * 3 + 1] = aColours[i * 3 + 1] + u[j];
+ colorList[j][i * 3 + 2] = aColours[i * 3 + 2] + v[j];
+ }
+ }
+}
+
+void
+Renderer::Draw(void)
+{
+
+ float glScale = (float)GLtools::getWidth() / GLtools::getHeight();
+ float cScale = (float)CameraTools::GetWidth() / CameraTools::GetHeight();
+
+ float scaleWidth = 1.0f;
+ float scaleHeight = 1.0f;
+
+
+
+
+ if(cScale < glScale)
+ {
+ scaleHeight = cScale / glScale;
+ } else {
+ scaleWidth = cScale / glScale;
+ }
+
+
+ float widthShift = (1.f - scaleWidth) / 2.f;
+ float heightShift = (1.f - scaleHeight) / 2.f ;
+
+
+ GLfloat vVertices[] = {
+ -1.0f , 1.0f , 0.0f, // Position 0
+ 0.0f , heightShift , // TexCoord 0
+ 0.f , 0.0f , 0.0f, // Color
+
+ -1.0f , -1.0f, 0.0f , // Position 1
+ 0.0f , scaleHeight + heightShift, // TexCoord 1
+ 0.0f , 0.f , 0.f, // Color
+
+ 1.0f , -1.0f, 0.0f, // Position 2
+ scaleWidth + widthShift, scaleHeight + heightShift, // TexCoord 2
+ 0.0f , 0.0f , 0.0f, // Color
+
+ 1.0f , 1.0f , 0.0f, // Position 3
+ scaleWidth + widthShift, heightShift , // TexCoord 3
+ 0.0f , 0.0f , 0.0f // Color
+ };
+
+
+
+ GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
+
+ perspectiveMatrix (__cameraAngle, (double)GLtools::getWidth()/(double)GLtools::getHeight(), 0.01, 100.0, __perspectiveMatrix);
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+ glUseProgram (__programObject);
+
+ glVertexAttribPointer (__positionLoc, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), vVertices);
+ glVertexAttribPointer (__texCoordLoc, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), &vVertices[3]);
+ glVertexAttribPointer (__colorLoc, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), &vVertices[5]);
+
+ glEnableVertexAttribArray (__positionLoc);
+ glEnableVertexAttribArray (__texCoordLoc);
+ glEnableVertexAttribArray (__colorLoc);
+
+ glUniformMatrix4fv (__mvpPLoc, 1, GL_FALSE, __mvp2); // GL_CHECK
+
+ glActiveTexture (GL_TEXTURE1);
+ glBindTexture (GL_TEXTURE_2D, __textureColorId);
+ glUniform1i (__samplerColorLoc, 1);
+
+ glActiveTexture (GL_TEXTURE0);
+ glBindTexture (GL_TEXTURE_2D, __textureId);
+ glUniform1i (__samplerLoc, 0);
+
+ glDisable (GL_DEPTH_TEST);
+ glDrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
+
+ glVertexAttribPointer (__positionLoc, 3, GL_FLOAT, GL_FALSE, 0, aVertices);
+ glVertexAttribPointer (__texCoordLoc, 2, GL_FLOAT, GL_FALSE, 0, aTexCoords);
+
+ glEnable (GL_CULL_FACE);
+ glEnable (GL_DEPTH_TEST);
+
+ glActiveTexture (GL_TEXTURE1);
+ glBindTexture (GL_TEXTURE_2D, -1);
+ glActiveTexture (GL_TEXTURE0);
+ glBindTexture (GL_TEXTURE_2D, -1);
+
+ float mvp[16];
+ for(int i = 0; i < CUBE_COUNT; ++i)
+ {
+ multiplyMatrix(__perspectiveMatrix, __modelView[i], mvp);
+ glUniformMatrix4fv (__mvpPLoc, 1, GL_FALSE, mvp); // GL_CHECK
+ glVertexAttribPointer (__colorLoc, 3, GL_FLOAT, GL_FALSE, 0, colorList[i % 3]);
+ glDrawArrays (GL_TRIANGLES, 0, 36);
+ }
+}
+
+GLuint
+Renderer::loadShader(GLenum type, const char *shaderSrc)
+{
+ GLuint shader;
+ GLint compiled;
+
+ shader = glCreateShader (type);
+
+ if (shader == 0)
+ return 0;
+
+ // Load the shader source
+ glShaderSource (shader, 1, &shaderSrc, NULL);
+
+ // Compile the shader
+ glCompileShader (shader);
+
+ // Check the compile status
+ glGetShaderiv (shader, GL_COMPILE_STATUS, &compiled);
+
+ if (!compiled)
+ {
+ GLint infoLen = 0;
+
+ glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &infoLen);
+
+ if (infoLen > 1)
+ {
+ char* infoLog = (char*)malloc (sizeof(char) * infoLen);
+
+ glGetShaderInfoLog (shader, infoLen, NULL, infoLog);
+ AppLogExceptionTag ("QrCodeRecognizer", "Error compiling shader:\n%s\n", infoLog);
+
+ free (infoLog);
+ }
+
+ glDeleteShader (shader);
+ return 0;
+ }
+
+ return shader;
+
+}
+
+GLuint
+Renderer::loadProgram(const char *vertShaderSrc, const char *fragShaderSrc)
+{
+ GLuint vertexShader;
+ GLuint fragmentShader;
+ GLuint programObject;
+ GLint linked;
+
+ // Load the vertex/fragment shaders
+ vertexShader = loadShader (GL_VERTEX_SHADER, vertShaderSrc);
+ if (vertexShader == 0)
+ return 0;
+
+ fragmentShader = loadShader (GL_FRAGMENT_SHADER, fragShaderSrc);
+ if (fragmentShader == 0)
+ {
+ glDeleteShader(vertexShader);
+ return 0;
+ }
+
+ // Create the program object
+ programObject = glCreateProgram ();
+
+ if (programObject == 0)
+ return 0;
+
+ glAttachShader (programObject, vertexShader);
+ glAttachShader (programObject, fragmentShader);
+
+ // Link the program
+ glLinkProgram (programObject);
+
+ // Check the link status
+ glGetProgramiv (programObject, GL_LINK_STATUS, &linked);
+
+ if (!linked)
+ {
+ GLint infoLen = 0;
+
+ glGetProgramiv (programObject, GL_INFO_LOG_LENGTH, &infoLen);
+
+ if (infoLen > 1)
+ {
+ char* infoLog = (char*)malloc (sizeof(char) * infoLen);
+
+ glGetProgramInfoLog (programObject, infoLen, NULL, infoLog);
+ AppLogExceptionTag("ImageRecognizer", "Error linking program: %s", infoLog);
+
+ free (infoLog);
+ }
+
+ glDeleteProgram (programObject);
+ return 0;
+ }
+
+ // Free up no longer needed shader resources
+ glDeleteShader (vertexShader);
+ glDeleteShader (fragmentShader);
+
+ return programObject;
+}
+
+GLuint
+Renderer::createSimpleTexture2D(GLenum type, int width, int height)
+{
+ // Create a simple 2x2 texture image with four different colors
+ // Texture object handle
+ GLuint textureId;
+
+ GLubyte* pixels = new GLubyte[width * height * 4];
+
+ // Generate a texture object
+ glGenTextures (1, &textureId);
+
+ // Bind the texture object
+ glBindTexture (GL_TEXTURE_2D, textureId);
+
+ // Load the texture
+ glTexImage2D (GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels);
+
+ // Set the filtering mode
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ delete[] pixels;
+
+ return textureId;
+}
+
+void
+Renderer::rotateMatrix(double angle, double x, double y, double z, float *R)
+{
+ double radians, c, s, c1, u[3], length;
+ int i, j;
+
+ radians = (angle * M_PI) / 180.0;
+
+ c = cos(radians);
+ s = sin(radians);
+
+ c1 = 1.0 - cos(radians);
+
+ length = sqrt(x * x + y * y + z * z);
+
+ u[0] = x / length;
+ u[1] = y / length;
+ u[2] = z / length;
+
+ for (i = 0; i < 16; i++)
+ {
+ R[i] = 0.0;
+ }
+
+ R[15] = 1.0;
+
+ for (i = 0; i < 3; i++)
+ {
+ R[i * 4 + (i + 1) % 3] = float(u[(i + 2) % 3] * s);
+ R[i * 4 + (i + 2) % 3] = float(-u[(i + 1) % 3] * s);
+ }
+
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+ R[i * 4 + j] += float(c1 * u[i] * u[j] + (i == j ? c : 0.0));
+ }
+ }
+}
+
+void
+Renderer::perspectiveMatrix(double fovy, double aspect, double znear, double zfar, float *P)
+{
+ int i;
+ double f;
+
+ f = 1.0/tan(fovy * 0.5);
+
+ for (i = 0; i < 16; i++)
+ {
+ P[i] = 0.0f;
+ }
+
+ P[0] = float(f);
+ P[5] = float(f * aspect);
+ P[10] = float((znear + zfar) / (znear - zfar));
+ P[11] = -1.0f;
+ P[14] = float((2.0 * znear * zfar) / (znear - zfar));
+ P[15] = 0.0f;
+}
+
+void
+Renderer::multiplyMatrix(const float *A, const float *B, float *C)
+{
+ int i, j, k;
+ float aTmp[16];
+
+ for (i = 0; i < 4; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ aTmp[j * 4 + i] = 0.0f;
+
+ for (k = 0; k < 4; k++)
+ {
+ aTmp[j * 4 + i] += A[k * 4 + i] * B[j * 4 + k];
+ }
+ }
+ }
+
+ for (i = 0; i < 16; i++)
+ {
+ C[i] = aTmp[i];
+ }
+}
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#include <FApp.h>
+#include "TouchForm.h"
+
+TouchForm::TouchForm(void)
+ : __pPanel(0)
+{
+}
+
+TouchForm::~TouchForm(void)
+{
+}
+
+bool
+TouchForm::Initialize(void)
+{
+ Construct(L"IDF_FORM");
+
+ return true;
+}
+
+result
+TouchForm::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+ AddTouchEventListener(*this);
+
+ __pPanel = static_cast<PanelButton*>(GetControl("IDC_BUTTON_PANEL"));
+ return r;
+}
+
+result
+TouchForm::OnTerminating(void)
+{
+ result r = E_SUCCESS;
+ return r;
+}
+
+void
+TouchForm::OnTouchLongPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo)
+{
+}
+
+void
+TouchForm::OnTouchMoved(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo)
+{
+}
+
+void
+TouchForm::OnTouchPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo)
+{
+}
+
+void
+TouchForm::OnTouchReleased(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo)
+{
+ static int __clicked = 0;
+ if (3 <= __clicked)
+ {
+ if (__pPanel)
+ {
+ if (!__pPanel->GetShowState())
+ {
+ __pPanel->SetEnabled(true);
+ __pPanel->SetShowState(true);
+ }
+ }
+ __clicked = 0;
+ }
+ ++__clicked;
+}
+
+void
+TouchForm::OnTouchDoublePressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo)
+{
+}
+
+void
+TouchForm::OnTouchFocusIn(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo)
+{
+}
+
+void
+TouchForm::OnTouchFocusOut(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo)
+{
+}
+
+void
+TouchForm::Activate(void)
+{
+ this->SetShowState(true);
+ this->SetEnabled(true);
+ Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
+ pFrame->SetCurrentForm(*this);
+ this->RequestRedraw(true);
+ AddTouchEventListener(*this);
+}
+
+void
+TouchForm::Deactivate(void)
+{
+ this->SetEnabled(false);
+ this->SetShowState(false);
+ RemoveTouchEventListener(*this);
+}
+
+void
+TouchForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
+{
+ switch(requestId)
+ {
+ case TouchForm::REQUEST_ACTIVATE:
+ {
+ Activate();
+ break;
+ }
+ case TouchForm::REQUEST_DEACTIVATE:
+ {
+ Deactivate();
+ break;
+ }
+ default:
+ break;
+ }
+}
+
--- /dev/null
+//
+// Tizen Native SDK
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+// All rights reserved.
+//
+// This software contains confidential and proprietary information
+// of Samsung Electronics Co., Ltd.
+// The user of this software agrees not to disclose, disseminate or copy such
+// Confidential Information and shall use the software only in accordance with
+// the terms of the license agreement the user entered into with Samsung.
+//
+
+#include "Tracker.h"
+#include "CameraTools.h"
+
+#include <FApp.h>
+#include <FIo.h>
+#include <FUixVisionQrCodeObject.h>
+
+Tracker::Tracker()
+ : __pQrRecognizer(0)
+ , __pRenderer(0)
+ , __pRoi(0)
+ , __pLabel(0)
+ , __pForm(0)
+ , __doRender(true)
+ , __terminating(false)
+{
+}
+
+Tracker::~Tracker()
+{
+ delete __pQrRecognizer;
+ delete __pRenderer;
+ delete __pRoi;
+}
+
+void
+Tracker::Init(Tizen::Ui::Controls::Form* form)
+{
+ __pRenderer = new Renderer();
+ __pRenderer->SetCameraAngle(0.4636476*2);
+ __pRenderer->Init(CameraTools::GetWidth(), CameraTools::GetHeight());
+ __pRoi = new Tizen::Graphics::Rectangle;
+ __pLabel = static_cast<Tizen::Ui::Controls::Label *>(form->GetControl("IDC_INFO_LABEL"));
+ __pForm = form;
+
+ InitRecognizer();
+}
+
+void
+Tracker::InitRecognizer(void)
+{
+ __pQrRecognizer = new Tizen::Uix::Vision::QrCodeRecognizer();
+ __pQrRecognizer->Construct();
+ __pQrRecognizer->SetImageSize(CameraTools::GetWidth(), CameraTools::GetHeight());
+}
+
+// Called when camera auto focus occurred
+void
+Tracker::OnCameraAutoFocused(bool completeCondition)
+{
+}
+
+// Called when camera preview occurred
+void
+Tracker::OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r)
+{
+ if (__doRender && !__terminating)
+ {
+ bool was_object = false;
+ __pQrRecognizer->ProcessImage(previewedData);
+
+ if (GLtools::startDrawing())
+ {
+ __pRenderer->SetTextureData(CameraTools::GetWidth(), CameraTools::GetHeight(), (unsigned char*) previewedData.GetPointer());
+ static float zeroBuffer[4][4] = {{ 0, 0, 0, 0}};
+ static Tizen::Graphics::FloatMatrix4 zeroMatrix(zeroBuffer);
+ __pRenderer->SetModelViewMatrix(0, &zeroMatrix);
+ __pLabel->SetText("");
+
+ for (int i = 0; i < __pQrRecognizer->GetRecognizedObjectCount(); i++)
+ {
+ const Tizen::Uix::Vision::QrCodeObject *o = __pQrRecognizer->GetRecognizedObject(i);
+ //Tracking QR but cannot read the message
+ if (o->GetText().IsEmpty())
+ {
+ //Leaving message same
+ __pLabel->SetText(__qrText);
+ }
+ else
+ {
+ //Changing message
+ __qrText = o->GetText();
+ __pLabel->SetText(o->GetText());
+ }
+ __pRenderer->SetModelViewMatrix(0, o->GetTransformMatrix());
+ was_object = true;
+ }
+// Focus(was_object);
+ __pRenderer->Draw();
+ GLtools::finishDrawing();
+ }
+
+ __pForm->Draw();
+ }
+ else if (__terminating)
+ {
+ __terminating = false;
+ __doRender = false;
+ Tizen::App::Application::GetInstance()->Terminate();
+ }
+}
+
+// Called when camera captured image
+void
+Tracker::OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData, result r)
+{
+}
+
+// Called when camera error occurred
+void
+Tracker::OnCameraErrorOccurred(Tizen::Media::CameraErrorReason r)
+{
+}
+
+void
+Tracker::DoRendering(bool render)
+{
+ __doRender = render;
+}
+
+Tizen::Base::String
+Tracker::GetTextMessage(void)
+{
+ if (__pQrRecognizer->GetRecognizedObjectCount() > 0)
+ return __qrText;
+ else
+ return Tizen::Base::String(L"");
+}
+void
+Tracker::Terminate(void)
+{
+ __terminating = true;
+}
+
+void
+Tracker::Focus(bool objectVisible)
+{
+ static unsigned int frames = 0;
+ static Tizen::Graphics::Point pt(0, 0);
+ Tizen::Base::Collection::ArrayList list;
+
+ frames++;
+
+ if (frames >= 60)
+ {
+ if( (objectVisible) && (E_SUCCESS == __pQrRecognizer->GetFocusRoi(*__pRoi)) )
+ {
+ float x = 0, y = 0;
+ x = __pRoi->x + __pRoi->width / 2;
+ y = __pRoi->y + __pRoi->height / 2;
+ pt.SetPosition((x + 0.5) * CameraTools::GetWidth(), (y + 0.5) * CameraTools::GetHeight());
+ } else {
+ pt.SetPosition(CameraTools::GetWidth() >> 1, CameraTools::GetHeight() >> 1);
+ }
+
+ static bool already_focused = false;
+ if(!(objectVisible && already_focused))
+ {
+ list.RemoveAll(false);
+ list.Add(pt);
+ CameraTools::GetCamera()->SetAutoFocusPoint(list);
+ CameraTools::GetCamera()->SetAutoFocus(false);
+ already_focused = objectVisible;
+ }
+ frames = 0;
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<template>
+
+ <slp-property>
+ <property-group>
+ <sample-name>QrCodeRecognizer</sample-name>
+ <category>Sample</category>
+ <sdk-version>1.00</sdk-version>
+ <project-type>org.tizen.nativecpp.buildArtefactType.app</project-type>
+ <sample-description>description.xml</sample-description>
+ </property-group>
+ </slp-property>
+
+ <process type="org.tizen.nativeappcommon.TizenCopyFolder">
+ <simple name="projectName" value="$(projectName)"/>
+ <simple name="folderPath" value="project"/>
+ <complex-array name="replaceableFiles">
+ <element>
+ <simple name="sourcePath" value="manifest.xml"/>
+ <simple name="targetPath" value="manifest.xml"/>
+ <simple name="replaceable" value = "true"/>
+ </element>
+ </complex-array>
+ </process>
+ <process type="org.tizen.nativecpp.SetDefaultFrameworks">
+ <simple name="projectName" value="$(projectName)"/>
+ <complex-array name="frameworkList">
+ <element>
+ <simple name="framework" value="osp"/>
+ </element>
+ </complex-array>
+ </process>
+
+</template>