summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyungKyu Song <hk76.song@samsung.com>2013-02-16 00:56:13 +0900
committerHyungKyu Song <hk76.song@samsung.com>2013-02-16 00:56:13 +0900
commit788035927063911d78a0f1bff87c2cb49ab41d70 (patch)
tree22c02a557e984e78d4a818c21b34d913598ef3ec
parente095ca0bf2dcdac997ede899fa83322c736fa75a (diff)
downloadFaceTracker-tizen_2.0.tar.gz
FaceTracker-tizen_2.0.tar.bz2
FaceTracker-tizen_2.0.zip
-rw-r--r--LICENSE206
-rw-r--r--NOTICE4
-rw-r--r--description.xml10
-rw-r--r--project/data/nofile.dummy0
-rw-r--r--project/inc/FaceData.h48
-rwxr-xr-xproject/inc/FaceThread.h62
-rwxr-xr-xproject/inc/FaceTracker.h75
-rwxr-xr-xproject/inc/FaceTrackerForm.h69
-rw-r--r--project/inc/FaceTrackerFrame.h35
-rwxr-xr-xproject/manifest.xml28
-rwxr-xr-xproject/res/sample1.bmpbin0 -> 230454 bytes
-rwxr-xr-xproject/res/screen-density-xhigh/tizen.pngbin0 -> 39063 bytes
-rwxr-xr-xproject/res/screen-size-normal/IDF_FORM.xml22
-rwxr-xr-xproject/shared/data/nofile.dummy0
-rwxr-xr-xproject/shared/res/screen-density-xhigh/mainmenu.pngbin0 -> 17581 bytes
-rwxr-xr-xproject/shared/trusted/nofile.dummy0
-rwxr-xr-xproject/src/FaceData.cpp88
-rwxr-xr-xproject/src/FaceThread.cpp205
-rwxr-xr-xproject/src/FaceTracker.cpp140
-rw-r--r--project/src/FaceTrackerEntry.cpp56
-rw-r--r--project/src/FaceTrackerForm.cpp387
-rw-r--r--project/src/FaceTrackerFrame.cpp61
-rw-r--r--sample.xml34
-rwxr-xr-xscreenshot.pngbin0 -> 33850 bytes
24 files changed, 1530 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..917b21e
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,206 @@
+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.
+
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..3997999
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,4 @@
+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.
+
diff --git a/description.xml b/description.xml
new file mode 100644
index 0000000..e30785b
--- /dev/null
+++ b/description.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/xsl" href="../../../../description.xsl"?>
+
+<Overview version="0.17.1">
+ <SampleName> FaceTracker </SampleName>
+ <SampleVersion>1.0</SampleVersion>
+ <Preview>screenshot.png</Preview>
+ <Description>The FaceTracker sample application demonstrates how you can enable your device to detect and track faces.
+ </Description>
+</Overview>
diff --git a/project/data/nofile.dummy b/project/data/nofile.dummy
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/data/nofile.dummy
diff --git a/project/inc/FaceData.h b/project/inc/FaceData.h
new file mode 100644
index 0000000..83c24fd
--- /dev/null
+++ b/project/inc/FaceData.h
@@ -0,0 +1,48 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#ifndef _FACE_DATA_H_
+#define _FACE_DATA_H_
+
+#include <FBase.h>
+#include <FGraphics.h>
+
+class FaceData
+ : public Tizen::Base::Object
+{
+public:
+ FaceData(void);
+ virtual ~FaceData(void);
+
+ void SetRectangle(Tizen::Graphics::Rectangle rect);
+ void SetSimilarity(int simil);
+ void SetFaceDetected(bool isFaceDetect);
+ void SetThreadCompleted(bool isThreadComplete);
+
+ Tizen::Graphics::Rectangle GetRectangle(void);
+ int GetSimilarity(void);
+ bool GetFaceDetected(void);
+ bool GetThreadCompleted(void);
+private:
+ Tizen::Graphics::Rectangle __faceRect;
+ int __similarity;
+ bool __isFaceDetected;
+ bool __isThreadCompleted;
+};
+
+
+#endif /* _FACEDATA_H_ */
diff --git a/project/inc/FaceThread.h b/project/inc/FaceThread.h
new file mode 100755
index 0000000..89fa674
--- /dev/null
+++ b/project/inc/FaceThread.h
@@ -0,0 +1,62 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#ifndef _FACE_THREAD_H_
+#define _FACE_THREAD_H_
+
+#include <FBase.h>
+#include <FUi.h>
+#include <FApp.h>
+#include <FGraphics.h>
+#include <FMedia.h>
+#include <FUix.h>
+#include "FaceData.h"
+
+enum RunMode
+{
+ RUN_MODE_FACE_DETECTION,
+ RUN_MODE_FACE_TRACKING,
+};
+
+class FaceThread
+ : public Tizen::Base::Runtime::Thread
+{
+
+public:
+ FaceThread(void);
+ virtual ~FaceThread(void);
+ result Construct(void);
+
+ virtual bool OnStart(void);
+ virtual void OnStop(void);
+ virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList *pArgs);
+
+ void SetFaceDetectData(Tizen::Uix::Vision::FaceDetector *pFD, Tizen::Uix::Vision::FaceRecognizer *pFR, Tizen::Uix::Vision::FaceRecognitionInfo *pFI, FaceData *pFaceData, Tizen::Ui::Controls::Form* pForm);
+
+private:
+ Tizen::Uix::Vision::FaceDetector* __pFaceDetector;
+ Tizen::Uix::Vision::FaceRecognizer* __pFaceReconizer;
+ Tizen::Uix::Vision::FaceRecognitionInfo* __pFInfoReference;
+ Tizen::Uix::Vision::FaceComponentsPosition* __pFaceComponents;
+ Tizen::Graphics::Rectangle* __pFaceRect;
+ Tizen::Ui::Controls::Form* __pFaceTrackerForm;
+ FaceData* __pFaceData;
+ Tizen::Uix::Vision::FaceBuffer* __pPrevFaceBuffer;
+ Tizen::Uix::Vision::FaceBuffer* __pCurFaceBuffer;
+};
+
+#endif /* _FACE_THREAD_H_ */
diff --git a/project/inc/FaceTracker.h b/project/inc/FaceTracker.h
new file mode 100755
index 0000000..27a45bd
--- /dev/null
+++ b/project/inc/FaceTracker.h
@@ -0,0 +1,75 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#ifndef _FACE_TRACKER_H_
+#define _FACE_TRACKER_H_
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FSystem.h>
+#include <FUi.h>
+
+/**
+ * [FaceTrackerApp] UiApp must inherit from UiApp class
+ * which provides basic features necessary to define an UiApp.
+ */
+class FaceTrackerApp
+ : public Tizen::App::UiApp
+ , public Tizen::System::IScreenEventListener
+ , public Tizen::System::IDeviceEventListener
+{
+public:
+ FaceTrackerApp(void);
+ virtual~FaceTrackerApp(void);
+
+ static Tizen::App::UiApp* CreateInstance(void);
+
+ // Called when the UiApp is initializing.
+ virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
+
+ // Called when the UiApp initializing is finished.
+ virtual bool OnAppInitialized(void);
+
+ // Called when the UiApp is requested to terminate.
+ virtual bool OnAppWillTerminate(void);
+
+ // Called when the UiApp is terminating.
+ virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
+
+ // Called when the UiApp's frame moves to the top of the screen.
+ virtual void OnForeground(void);
+
+ // Called when this UiApp's frame is moved from top of the screen to the background.
+ virtual void OnBackground(void);
+
+ // Called when the system memory is not sufficient to run the UiApp any further.
+ virtual void OnLowMemory(void);
+
+ // Called when the battery level changes.
+ virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
+
+ // Called when device is connected or removed
+ virtual void OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String &state);
+
+ // Called when the screen turns on.
+ virtual void OnScreenOn(void);
+
+ // Called when the screen turns off.
+ virtual void OnScreenOff(void);
+};
+
+#endif
diff --git a/project/inc/FaceTrackerForm.h b/project/inc/FaceTrackerForm.h
new file mode 100755
index 0000000..1c6c8a6
--- /dev/null
+++ b/project/inc/FaceTrackerForm.h
@@ -0,0 +1,69 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#ifndef _FACE_TRACKER_FORM_H_
+#define _FACE_TRACKER_FORM_H_
+
+#include <FBase.h>
+#include <FUi.h>
+#include <FSystem.h>
+#include <FUix.h>
+#include <FMedia.h>
+#include <FGraphics.h>
+#include "FaceData.h"
+#include "FaceThread.h"
+
+class FaceTrackerForm
+ : public Tizen::Ui::Controls::Form
+ , public Tizen::Ui::Controls::IFormBackEventListener
+ , public Tizen::Media::ICameraEventListener
+{
+public:
+ FaceTrackerForm(void);
+ virtual ~FaceTrackerForm(void);
+ bool Initialize(void);
+
+ virtual result OnInitializing(void);
+ virtual result OnTerminating(void);
+ virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
+ virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList *pArgs);
+ void StartCamera(void);
+ void StopCamera(void);
+ result CheckBatteryLevel(Tizen::System::BatteryLevel level);
+
+ //Camera EventListner
+ void OnCameraAutoFocused(bool completeCondition);
+ void OnCameraPreviewed( Tizen::Base::ByteBuffer& previewedData, result r);
+ void OnCameraCaptured( Tizen::Base::ByteBuffer& capturedData, result r);
+ void OnCameraErrorOccurred(Tizen::Media::CameraErrorReason r );
+
+private:
+ Tizen::Graphics::Rectangle __rect;
+ Tizen::Uix::Vision::FaceDetector* __pFaceDetector;
+ Tizen::Uix::Vision::FaceRecognizer* __pFaceRecognizer;
+ FaceData* __pFaceData;
+ Tizen::Uix::Vision::FaceRecognitionInfo* __pFInfoReference;
+ Tizen::Ui::Controls::OverlayRegion* __pOverlayRegion;
+ Tizen::Graphics::BufferInfo __bufferInfo;
+ Tizen::Graphics::Canvas* __pCanvas;
+ Tizen::Ui::Controls::Panel* __pPanel;
+ Tizen::Media::Camera* __pCamera;
+ FaceThread *__pFaceThread;
+ bool __isCameraOn;
+};
+
+#endif //_FACE_TRACKER_FORM_H_
diff --git a/project/inc/FaceTrackerFrame.h b/project/inc/FaceTrackerFrame.h
new file mode 100644
index 0000000..a3d548c
--- /dev/null
+++ b/project/inc/FaceTrackerFrame.h
@@ -0,0 +1,35 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#ifndef _FACE_TRACKER_FRAME_H_
+#define _FACE_TRACKER_FRAME_H_
+
+#include <FBase.h>
+#include <FUi.h>
+
+class FaceTrackerFrame
+ : public Tizen::Ui::Controls::Frame
+{
+public:
+ FaceTrackerFrame(void);
+ virtual ~FaceTrackerFrame(void);
+
+ virtual result OnInitializing(void);
+ virtual result OnTerminating(void);
+};
+
+#endif //_FACE_TRACKER_FRAME_H_
diff --git a/project/manifest.xml b/project/manifest.xml
new file mode 100755
index 0000000..2a2d6c0
--- /dev/null
+++ b/project/manifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest">
+ <Id>$(manifestAppId)</Id>
+ <Version>1.0.0</Version>
+ <Type>C++App</Type>
+ <Author/>
+ <Apps>
+ <ApiVersion>2.0</ApiVersion>
+ <Privileges>
+ <Privilege>http://tizen.org/privilege/camera</Privilege>
+ <Privilege>http://tizen.org/privilege/alarm</Privilege>
+ <Privilege>http://tizen.org/privilege/power</Privilege>
+ </Privileges>
+ <UiApp Main="True" MenuIconVisible="True" Name="$(projectName)" HwAcceleration="On" >
+ <UiScalability BaseScreenSize="Normal" CoordinateSystem="Logical" LogicalCoordinate="480"></UiScalability>
+ <UiTheme SystemTheme="White"/>
+ <DisplayNames>
+ <DisplayName Locale="eng-GB">$(projectName)</DisplayName>
+ </DisplayNames>
+ <Icons>
+ <Icon Section="MainMenu" Type="Xhigh">mainmenu.png</Icon>
+ </Icons>
+ <AppControls></AppControls>
+ <LaunchConditions></LaunchConditions>
+ <Notifications></Notifications>
+ </UiApp>
+ </Apps>
+</Manifest>
diff --git a/project/res/sample1.bmp b/project/res/sample1.bmp
new file mode 100755
index 0000000..9c8ff2e
--- /dev/null
+++ b/project/res/sample1.bmp
Binary files differ
diff --git a/project/res/screen-density-xhigh/tizen.png b/project/res/screen-density-xhigh/tizen.png
new file mode 100755
index 0000000..56040da
--- /dev/null
+++ b/project/res/screen-density-xhigh/tizen.png
Binary files differ
diff --git a/project/res/screen-size-normal/IDF_FORM.xml b/project/res/screen-size-normal/IDF_FORM.xml
new file mode 100755
index 0000000..fa27840
--- /dev/null
+++ b/project/res/screen-size-normal/IDF_FORM.xml
@@ -0,0 +1,22 @@
+<?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="3.0.0.v20120705" Dversion="20120315">
+ <LogicalCoordinate>480</LogicalCoordinate>
+ <Form id="IDF_FORM">
+ <property backgroundColor="" backgroundColorOpacity="100" orientation="Landscape" softKey0NormalIcon="" softKey0PressedIcon="" softKey0Text="" softKey1NormalIcon="" softKey1PressedIcon="" softKey1Text="" title="" titleAlign="ALIGN_CENTER" titleIcon="" translucentFooter="false" translucentHeader="false" translucentIndicator="false"/>
+ <layout mode="Portrait" style="FORM_STYLE_INDICATOR|FORM_STYLE_HEADER|FORM_STYLE_FOOTER" type="LAYOUT_RELATIVE"/>
+ <layout mode="Landscape" style="FORM_STYLE_INDICATOR|FORM_STYLE_HEADER|FORM_STYLE_FOOTER" type="LAYOUT_RELATIVE"/>
+ </Form>
+ <Footer>
+ <property backgroundBitmapPath="" color="" colorOpacity="0" disabledButtonColor="" disabledButtonColorOpacity="0" disabledButtonTextColor="" disabledItemColor="" disabledItemColorOpacity="0" disabledItemTextColor="" footerStyle="FOOTER_STYLE_BUTTON_TEXT" highlightedButtonColor="" highlightedButtonColorOpacity="0" highlightedButtonTextColor="" highlightedItemColor="" highlightedItemColorOpacity="0" highlightedItemTextColor="" normalButtonColor="" normalButtonColorOpacity="0" normalButtonTextColor="" normalItemColor="" normalItemColorOpacity="0" normalItemTextColor="" pressedButtonColor="" pressedButtonColorOpacity="0" pressedButtonTextColor="" pressedItemColor="" pressedItemColorOpacity="0" pressedItemTextColor="" selectedItemColor="" selectedItemColorOpacity="0" selectedItemTextColor="" showBackButton="true"/>
+ <itemSet/>
+ </Footer>
+ <Header>
+ <property backgroundBitmapPath="" color="" colorOpacity="0" descriptionText="" descriptionTextColor="" disabledButtonColor="" disabledButtonColorOpacity="0" disabledButtonTextColor="" disabledItemColor="" disabledItemColorOpacity="0" disabledItemTextColor="" headerStyle="HEADER_STYLE_TITLE" highlightedButtonColor="" highlightedButtonColorOpacity="0" highlightedButtonTextColor="" highlightedItemColor="" highlightedItemColorOpacity="0" highlightedItemTextColor="" normalButtonColor="" normalButtonColorOpacity="0" normalButtonTextColor="" normalItemColor="" normalItemColorOpacity="0" normalItemTextColor="" pressedButtonColor="" pressedButtonColorOpacity="0" pressedButtonTextColor="" pressedItemColor="" pressedItemColorOpacity="0" pressedItemTextColor="" selectedItemColor="" selectedItemColorOpacity="0" selectedItemTextColor="" titleIconPath="" titleText="FACE TRACKER" titleTextColor=""/>
+ <itemSet/>
+ </Header>
+</Scene>
diff --git a/project/shared/data/nofile.dummy b/project/shared/data/nofile.dummy
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/project/shared/data/nofile.dummy
diff --git a/project/shared/res/screen-density-xhigh/mainmenu.png b/project/shared/res/screen-density-xhigh/mainmenu.png
new file mode 100755
index 0000000..983c883
--- /dev/null
+++ b/project/shared/res/screen-density-xhigh/mainmenu.png
Binary files differ
diff --git a/project/shared/trusted/nofile.dummy b/project/shared/trusted/nofile.dummy
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/project/shared/trusted/nofile.dummy
diff --git a/project/src/FaceData.cpp b/project/src/FaceData.cpp
new file mode 100755
index 0000000..5c4cce0
--- /dev/null
+++ b/project/src/FaceData.cpp
@@ -0,0 +1,88 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#include "FaceData.h"
+#include <FUix.h>
+
+using namespace Tizen::Uix::Vision;
+using namespace Tizen::Graphics;
+
+FaceData::FaceData(void)
+ : __similarity(0)
+ , __isFaceDetected(false)
+ , __isThreadCompleted(true)
+{
+}
+
+FaceData::~FaceData(void)
+{
+}
+
+void
+FaceData::SetRectangle(Tizen::Graphics::Rectangle rect)
+{
+ __faceRect.x = rect.x;
+ __faceRect.y = rect.y;
+ __faceRect.width = rect.width;
+ __faceRect.height = rect.height;
+}
+
+void
+FaceData::SetSimilarity(int similarity)
+{
+ __similarity = similarity;
+}
+
+void
+FaceData::SetFaceDetected(bool isFaceDetect)
+{
+ __isFaceDetected = isFaceDetect;
+}
+
+void
+FaceData::SetThreadCompleted(bool isThreadComplete)
+{
+ __isThreadCompleted = isThreadComplete;
+}
+
+Tizen::Graphics::Rectangle
+FaceData::GetRectangle(void)
+{
+ return __faceRect;
+}
+
+int
+FaceData::GetSimilarity(void)
+{
+ return __similarity;
+}
+
+bool
+FaceData::GetFaceDetected(void)
+{
+ return __isFaceDetected;
+}
+
+bool
+FaceData::GetThreadCompleted(void)
+{
+ return __isThreadCompleted;
+}
+
+
+
+
diff --git a/project/src/FaceThread.cpp b/project/src/FaceThread.cpp
new file mode 100755
index 0000000..68d5a58
--- /dev/null
+++ b/project/src/FaceThread.cpp
@@ -0,0 +1,205 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#include "FaceThread.h"
+
+#define SAFE_DELETE(x) if (x) { delete x; x = null; }
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Graphics;
+using namespace Tizen::Uix::Vision;
+using namespace Tizen::Ui::Controls;
+
+static const int PREVIEW_WIDTH = 320;
+static const int PREVIEW_HEIGHT = 240;
+
+
+FaceThread::FaceThread(void)
+ : __pFaceDetector(null)
+ , __pFaceReconizer(null)
+ , __pFInfoReference(null)
+ , __pFaceComponents(null)
+ , __pFaceRect(new Rectangle(0,0,0,0))
+ , __pFaceData(null)
+ , __pPrevFaceBuffer(null)
+ , __pCurFaceBuffer(null)
+{
+}
+
+FaceThread::~FaceThread(void)
+{
+ SAFE_DELETE(__pFaceRect);
+ SAFE_DELETE(__pFaceComponents);
+ SAFE_DELETE(__pPrevFaceBuffer);
+ SAFE_DELETE(__pCurFaceBuffer);
+}
+
+result
+FaceThread::Construct(void)
+{
+ Thread::Construct(THREAD_TYPE_EVENT_DRIVEN);
+ return E_SUCCESS;
+}
+
+bool
+FaceThread::OnStart(void)
+{
+ return true;
+}
+
+void
+FaceThread::OnStop(void)
+{
+ return;
+}
+
+void
+FaceThread::SetFaceDetectData(FaceDetector *pFD, FaceRecognizer *pFR, FaceRecognitionInfo *pFI, FaceData *pFaceData, Form* pForm)
+{
+ __pFaceDetector = pFD;
+ __pFaceReconizer = pFR;
+ __pFInfoReference = pFI;
+ __pFaceData = pFaceData;
+ __pFaceTrackerForm = pForm;
+
+ return;
+}
+
+void
+FaceThread::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
+{
+ __pFaceData->SetThreadCompleted(false);
+
+ ArrayList* pList = (Tizen::Base::Collection::ArrayList*)pArgs;
+ ByteBuffer* pCurBuffer = (ByteBuffer*)pList->GetAt(0);
+
+ __pCurFaceBuffer = __pFaceDetector->PreprocessDataN(*pCurBuffer, Dimension(PREVIEW_WIDTH, PREVIEW_HEIGHT), PIXEL_FORMAT_YCbCr420_PLANAR);
+
+ pList->RemoveAll();
+ SAFE_DELETE(pList);
+ SAFE_DELETE(pCurBuffer);
+
+ TryReturn(__pCurFaceBuffer != null, , "Failed to create FaceBuffer");
+
+ static int frameCnt = 20;
+ static int similarity = 0;
+ static RunMode runMode = RUN_MODE_FACE_DETECTION;
+
+ switch(runMode)
+ {
+ case RUN_MODE_FACE_DETECTION:
+ {
+ IList *pFaceDetectList = __pFaceDetector->DetectFacesN(*__pCurFaceBuffer);
+ if (pFaceDetectList != null)
+ {
+ if (pFaceDetectList->GetCount() > 0)
+ {
+ Rectangle* pFaceRect = (Tizen::Graphics::Rectangle*)pFaceDetectList->GetAt(0);
+ __pFaceRect->SetBounds(pFaceRect->x , pFaceRect->y , pFaceRect->width,pFaceRect->height);
+
+ pFaceDetectList->RemoveAll(true);
+ __pFaceData->SetFaceDetected(true);
+ }
+ else
+ {
+ __pFaceData->SetFaceDetected(false);
+ }
+
+ SAFE_DELETE(pFaceDetectList);
+ }
+ if (__pFaceData->GetFaceDetected() == false)
+ {
+ break;
+ }
+ __pFaceComponents = __pFaceDetector->ExtractFaceComponentsN(*__pCurFaceBuffer, *__pFaceRect);
+ if (__pFaceComponents == null)
+ {
+ break;
+ }
+ ByteBuffer* pFeatureBuffer = __pFaceReconizer->ExtractFeatureN(*__pCurFaceBuffer,*__pFaceComponents);
+ if (pFeatureBuffer != null)
+ {
+ FaceRecognitionInfo *pFInfoCurrent = new FaceRecognitionInfo();
+ if (pFInfoCurrent != null)
+ {
+ result r = pFInfoCurrent->Construct(*pFeatureBuffer);
+ if (r == E_SUCCESS)
+ {
+ similarity = __pFaceReconizer->MeasureSimilarity(*__pFInfoReference, *pFInfoCurrent);
+ }
+ }
+ SAFE_DELETE(pFInfoCurrent);
+ SAFE_DELETE(pFeatureBuffer);
+
+ runMode = RUN_MODE_FACE_TRACKING;
+ }
+ else
+ {
+ runMode = RUN_MODE_FACE_DETECTION;
+ }
+ SAFE_DELETE(__pFaceComponents);
+ break;
+ }
+ case RUN_MODE_FACE_TRACKING:
+ {
+ frameCnt--;
+ if (frameCnt == 0)
+ {
+ runMode = RUN_MODE_FACE_DETECTION;
+ frameCnt = 20;
+ }
+ int xDiff = 0;
+ int yDiff = 0;
+ if(E_SUCCESS == __pFaceDetector->GetFaceMovement(*__pPrevFaceBuffer, *__pCurFaceBuffer, *__pFaceRect, xDiff , yDiff))
+ {
+ __pFaceData->SetFaceDetected(true);
+ __pFaceRect->x += xDiff;
+ __pFaceRect->y += yDiff;
+ }
+ else
+ {
+ __pFaceData->SetFaceDetected(false);
+ runMode = RUN_MODE_FACE_DETECTION;
+ frameCnt = 20;
+ }
+ SAFE_DELETE(__pPrevFaceBuffer);
+ break;
+ }
+ default:
+ break;
+ }
+
+ if(runMode == RUN_MODE_FACE_TRACKING)
+ {
+ __pPrevFaceBuffer = __pCurFaceBuffer;
+ __pCurFaceBuffer = null;
+ }
+ else
+ {
+ SAFE_DELETE(__pCurFaceBuffer);
+ }
+
+ __pFaceData->SetRectangle(*__pFaceRect);
+ __pFaceData->SetSimilarity(similarity);
+
+ __pFaceTrackerForm->SendUserEvent(RUN_MODE_FACE_DETECTION, null);
+ __pFaceData->SetThreadCompleted(true);
+
+ return;
+}
diff --git a/project/src/FaceTracker.cpp b/project/src/FaceTracker.cpp
new file mode 100755
index 0000000..41dd3c0
--- /dev/null
+++ b/project/src/FaceTracker.cpp
@@ -0,0 +1,140 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#include "FaceTracker.h"
+#include "FaceTrackerFrame.h"
+#include "FaceTrackerForm.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::System;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+
+FaceTrackerApp::FaceTrackerApp(void)
+{
+}
+
+FaceTrackerApp::~FaceTrackerApp(void)
+{
+ DeviceManager::RemoveDeviceEventListener(Charger,*this);
+}
+
+UiApp*
+FaceTrackerApp::CreateInstance(void)
+{
+ return new (std::nothrow) FaceTrackerApp();
+}
+
+bool
+FaceTrackerApp::OnAppInitializing(AppRegistry& appRegistry)
+{
+ return true;
+}
+
+bool
+FaceTrackerApp::OnAppInitialized(void)
+{
+ DeviceManager::AddDeviceEventListener(Charger,*this);
+
+ FaceTrackerFrame* pFaceTrackerFrame = new (std::nothrow) FaceTrackerFrame();
+ TryReturn(pFaceTrackerFrame != null, false, "Failed to create FaceTrackerFrame");
+ result r = pFaceTrackerFrame->Construct();
+ TryReturn(r == E_SUCCESS, false, "Failed to construct FaceTrackerFrame");
+ pFaceTrackerFrame->SetName(L"FaceTracker");
+ AddFrame(*pFaceTrackerFrame);
+
+ return true;
+}
+
+bool
+FaceTrackerApp::OnAppWillTerminate(void)
+{
+ return true;
+}
+
+
+bool
+FaceTrackerApp::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+ return true;
+}
+
+void
+FaceTrackerApp::OnForeground(void)
+{
+ FaceTrackerForm *pFaceTrackerForm = (FaceTrackerForm *)(GetFrame(L"FaceTracker")->GetCurrentForm());
+ pFaceTrackerForm->StartCamera();
+}
+
+void
+FaceTrackerApp::OnBackground(void)
+{
+ FaceTrackerForm *pFaceTrackerForm = (FaceTrackerForm *)(GetFrame(L"FaceTracker")->GetCurrentForm());
+ pFaceTrackerForm->StopCamera();
+}
+
+void
+FaceTrackerApp::OnLowMemory(void)
+{
+}
+
+void
+FaceTrackerApp::OnBatteryLevelChanged(BatteryLevel batteryLevel)
+{
+ bool isCharging = false;
+
+ Tizen::System::RuntimeInfo::GetValue(String(L"IsCharging"),isCharging);
+
+ if (isCharging)
+ {
+ return;
+ }
+
+ if ((batteryLevel == BATTERY_LEVEL_LOW) || (batteryLevel == BATTERY_LEVEL_CRITICAL) || (batteryLevel == BATTERY_LEVEL_EMPTY))
+ {
+ MessageBox msgBox;
+ int modalResult = 0;
+ result r = msgBox.Construct("Warning","Battery is low. Terminating App.",MSGBOX_STYLE_NONE,4000);
+ TryReturn(r == E_SUCCESS, , "Failed to construct MessageBox");
+ msgBox.ShowAndWait(modalResult);
+
+ Application::GetInstance()->Terminate();
+ }
+}
+
+void
+FaceTrackerApp::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String &state)
+{
+ BatteryLevel level = BATTERY_FULL;
+
+ if (deviceType == Charger)
+ {
+ Tizen::System::Battery::GetCurrentLevel(level);
+ OnBatteryLevelChanged(level);
+ }
+}
+
+void
+FaceTrackerApp::OnScreenOn(void)
+{
+}
+
+void
+FaceTrackerApp::OnScreenOff(void)
+{
+}
diff --git a/project/src/FaceTrackerEntry.cpp b/project/src/FaceTrackerEntry.cpp
new file mode 100644
index 0000000..ccc89d7
--- /dev/null
+++ b/project/src/FaceTrackerEntry.cpp
@@ -0,0 +1,56 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+#include <new>
+#include "FaceTracker.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;
+
+ AppLog("Application started.");
+ ArrayList args;
+ args.Construct();
+ for (int i = 0; i < argc; i++)
+ {
+ args.Add(*(new (std::nothrow) String(pArgv[i])));
+ }
+
+ r = Tizen::App::UiApp::Execute(FaceTrackerApp::CreateInstance, &args);
+ TryLog(r == E_SUCCESS,"Application execution failed-[%s].", GetErrorMessage(r));
+
+ args.RemoveAll(true);
+ AppLog("Application finished.");
+
+ return static_cast<int>(r);
+}
+#ifdef __cplusplus
+}
+#endif // __cplusplus
diff --git a/project/src/FaceTrackerForm.cpp b/project/src/FaceTrackerForm.cpp
new file mode 100644
index 0000000..9707482
--- /dev/null
+++ b/project/src/FaceTrackerForm.cpp
@@ -0,0 +1,387 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#include <FApp.h>
+#include "FaceTrackerForm.h"
+
+#define SAFE_DELETE(x) if (x) { delete x; x = null; }
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::System;
+using namespace Tizen::App;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Graphics;
+using namespace Tizen::Uix::Vision;
+using namespace Tizen::Media;
+
+static const int X_OFFSET_FOR_CANVAS = 30;
+static const int Y_OFFSET_FOR_CAMVAS = 30;
+static const int PREVIEW_WIDTH = 320;
+static const int PREVIEW_HEIGHT = 240;
+static const int LINE_WIDTH = 4;
+static const unsigned int FG_COLOR = 0xFF0000FF;
+static const int FONT_SIZE = 40;
+
+FaceTrackerForm::FaceTrackerForm(void)
+ : __pFaceDetector(null)
+ , __pFaceRecognizer(null)
+ , __pFaceData(null)
+ , __pFInfoReference(null)
+ , __pOverlayRegion(null)
+ , __pCanvas(null)
+ , __pPanel(null)
+ , __pCamera(null)
+ , __pFaceThread(null)
+ , __isCameraOn(false)
+{
+}
+
+FaceTrackerForm::~FaceTrackerForm(void)
+{
+ __pFaceThread->Stop();
+ __pFaceThread->Join();
+ SAFE_DELETE(__pFaceThread);
+ SAFE_DELETE(__pCamera);
+ SAFE_DELETE(__pOverlayRegion);
+ SAFE_DELETE(__pCanvas);
+ SAFE_DELETE(__pFaceDetector);
+ SAFE_DELETE(__pFaceRecognizer);
+ SAFE_DELETE(__pFInfoReference);
+ SAFE_DELETE(__pFaceData);
+}
+
+bool
+FaceTrackerForm::Initialize(void)
+{
+ Construct(L"IDF_FORM");
+
+ return true;
+}
+
+result
+FaceTrackerForm::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+
+ int width = 0;
+ int height = 0;
+ FaceBuffer *pFaceBuffer = null;
+ Font font;
+ ByteBuffer *pBuffer = null;
+ Bitmap *pBitmap = null;
+ Label *pLabel = null;
+
+ __rect = GetClientAreaBounds();
+ Rectangle rect(__rect.x + X_OFFSET_FOR_CANVAS, Y_OFFSET_FOR_CAMVAS, PREVIEW_WIDTH, PREVIEW_HEIGHT);
+
+ __pFaceDetector = new (std::nothrow) FaceDetector();
+ TryReturn(__pFaceDetector != null, E_FAILURE, "Failed to create FaceDetector");
+ r = __pFaceDetector->Construct();
+ TryReturn(r == E_SUCCESS, E_FAILURE, "Failed to construct FaceDetector");
+
+ __pFaceRecognizer = new (std::nothrow) FaceRecognizer();
+ TryReturn(__pFaceRecognizer != null, E_FAILURE, "Failed to create FaceRecognizer");
+ r = __pFaceRecognizer->Construct();
+ TryReturn(r == E_SUCCESS, E_FAILURE, "Failed to construct FaceRecognizer");
+
+ __pFaceData = new (std::nothrow) FaceData();
+ TryReturn(__pFaceData != null, E_FAILURE, "Failed to create FaceData");
+
+ Image *pImage = new (std::nothrow) Image();
+ TryReturn(pImage != null, E_FAILURE, "Failed to create Image");
+ r = pImage->Construct();
+ TryCatch(r == E_SUCCESS, r = E_FAILURE, "Failed to construct Image");
+
+ pBuffer = pImage->DecodeToBufferN(Tizen::App::App::GetInstance()->GetAppRootPath()+L"res/sample1.bmp", BITMAP_PIXEL_FORMAT_RGB565,width,height);
+ SAFE_DELETE(pImage);
+
+ pBitmap = new (std::nothrow) Bitmap();
+ TryReturn(pBitmap != null, E_FAILURE, "Failed to create Bitmap");
+ r = pBitmap->Construct(*pBuffer, Dimension(width, height),BITMAP_PIXEL_FORMAT_RGB565 );
+ TryCatch(r == E_SUCCESS, r = E_FAILURE, "Failed to construct Bitmap");
+
+ pLabel = new (std::nothrow) Label();
+ TryCatch(pLabel != null, r = E_FAILURE, "Failed to create Label");
+ r = pLabel->Construct(Rectangle(__rect.width - X_OFFSET_FOR_CANVAS - PREVIEW_WIDTH, Y_OFFSET_FOR_CAMVAS, PREVIEW_WIDTH, PREVIEW_HEIGHT), L"");
+ TryCatch(r == E_SUCCESS, r = E_FAILURE, "Failed to construct Label");
+
+ pLabel->SetBackgroundBitmap(*pBitmap);
+ AddControl(*pLabel);
+ SAFE_DELETE(pBitmap);
+
+ pFaceBuffer = __pFaceDetector->PreprocessDataN(*pBuffer, Dimension(width, height), PIXEL_FORMAT_RGB565);
+ if (pFaceBuffer != null)
+ {
+ IList *pFaceDetectList = __pFaceDetector->DetectFacesN(*pFaceBuffer, FACE_DETECTION_OPTION_FAST);
+ if (pFaceDetectList != null)
+ {
+ if (pFaceDetectList->GetCount() > 0)
+ {
+ Rectangle *pFaceRect = (Tizen::Graphics::Rectangle*)pFaceDetectList->GetAt(0);
+ FaceComponentsPosition* pFaceComponents = __pFaceDetector->ExtractFaceComponentsN(*pFaceBuffer, *pFaceRect);
+ if(pFaceComponents)
+ {
+ ByteBuffer* pFeatureBuffer = __pFaceRecognizer->ExtractFeatureN(*pFaceBuffer,*pFaceComponents);
+ if (pFeatureBuffer != null)
+ {
+ __pFInfoReference = new (std::nothrow) FaceRecognitionInfo();
+ if (__pFInfoReference != null)
+ {
+ r = __pFInfoReference->Construct(*pFeatureBuffer);
+ }
+ SAFE_DELETE(pFeatureBuffer);
+ }
+ SAFE_DELETE(pFaceComponents);
+ }
+ }
+ pFaceDetectList->RemoveAll(true);
+ SAFE_DELETE(pFaceDetectList);
+ }
+ SAFE_DELETE(pFaceBuffer);
+ }
+ if (__pFInfoReference == null || r != E_SUCCESS)
+ {
+ return E_FAILURE;
+ }
+
+ __pPanel = new (std::nothrow) Panel();
+ TryReturn(__pPanel != null, E_FAILURE, "Failed to create Panel");
+ r = __pPanel->Construct(rect);
+ TryReturn(r == E_SUCCESS, E_FAILURE, "Failed to construct Panel");
+ AddControl(*__pPanel);
+ __pCanvas = __pPanel->GetCanvasN();
+ __pCanvas->SetLineWidth(LINE_WIDTH);
+ __pCanvas->SetForegroundColor(FG_COLOR);
+ __pCanvas->SetBackgroundColor(0x0);
+
+ r = font.Construct(FONT_STYLE_PLAIN, FONT_SIZE);
+ TryReturn(r == E_SUCCESS, E_FAILURE, "Failed to construct Font");
+ __pCanvas->SetFont(font);
+ __pCanvas->Clear();
+
+ __pCamera = new (std::nothrow) Camera();
+ TryReturn(__pCamera != null, E_FAILURE, "Failed to create Camera");
+ r = __pCamera->Construct(*this, CAMERA_PRIMARY);
+ TryReturn(r == E_SUCCESS, E_FAILURE, "Failed to construct Camera");
+
+ __pFaceThread = new (std::nothrow) FaceThread();
+ TryReturn(__pFaceThread != null, E_FAILURE, "Failed to create FaceThread");
+ r = __pFaceThread->Construct();
+ TryReturn(r == E_SUCCESS, E_FAILURE, "Failed to construct FaceThread");
+ __pFaceThread->SetFaceDetectData(__pFaceDetector, __pFaceRecognizer, __pFInfoReference, __pFaceData, this);
+ __pFaceThread->Start();
+ __pFaceData->SetThreadCompleted(true);
+
+ SetFormBackEventListener(this);
+ return r;
+
+CATCH:
+ SAFE_DELETE(pImage);
+ SAFE_DELETE(pBitmap);
+ SAFE_DELETE(pLabel);
+
+ return r;
+}
+
+result
+FaceTrackerForm::OnTerminating(void)
+{
+ StopCamera();
+ return E_SUCCESS;
+}
+
+void
+FaceTrackerForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
+{
+ UiApp* pApp = UiApp::GetInstance();
+ AppAssert(pApp);
+ pApp->Terminate();
+}
+
+void
+FaceTrackerForm::StartCamera(void)
+{
+ BatteryLevel level = BATTERY_FULL;
+
+ Tizen::System::Battery::GetCurrentLevel(level);
+
+ result r = CheckBatteryLevel(level);
+ if (r != E_SUCCESS)
+ {
+ return ;
+ }
+
+ if (!__pCamera->IsPoweredOn())
+ {
+ __pCamera->PowerOn();
+ }
+
+ if (__pCamera->IsPoweredOn())
+ {
+ __pCamera->SetPreviewFormat(PIXEL_FORMAT_YCbCr420_PLANAR);
+ __pCamera->SetPreviewResolution(Dimension(PREVIEW_WIDTH, PREVIEW_HEIGHT));
+
+ __rect = GetClientAreaBounds();
+ Rectangle rect(__rect.x + X_OFFSET_FOR_CANVAS, Y_OFFSET_FOR_CAMVAS, PREVIEW_WIDTH, PREVIEW_HEIGHT);
+
+ bool modified = false;
+ OverlayRegion::EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_LESS_THAN, rect, modified);
+ __pOverlayRegion = GetOverlayRegionN(rect, OVERLAY_REGION_TYPE_PRIMARY_CAMERA);
+ __pOverlayRegion->GetBackgroundBufferInfo(__bufferInfo);
+
+ r = __pCamera->StartPreview(&__bufferInfo, true);
+ TryCatch(r == E_SUCCESS, , "Start Preview failed");
+
+ r = Tizen::System::PowerManager::KeepScreenOnState(true, false);
+
+ __isCameraOn = true;
+ return;
+ }
+
+CATCH:
+ MessageBox msgBox;
+ int modalResult = 0;
+ r = msgBox.Construct("Warning","Camera is busy. Terminating App.",MSGBOX_STYLE_OK);
+ TryReturn(r == E_SUCCESS, , "Failed to construct MessageBox");
+ msgBox.ShowAndWait(modalResult);
+
+ if(modalResult == MSGBOX_RESULT_OK)
+ {
+ Application::GetInstance()->Terminate();
+ }
+
+ return;
+}
+
+void
+FaceTrackerForm::StopCamera(void)
+{
+ __pCanvas->Clear();
+ __pCanvas->Show();
+
+ if (__pCamera->IsPoweredOn())
+ {
+ __pCamera->StopPreview();
+ __pCamera->PowerOff();
+ }
+
+ __isCameraOn = false;
+ SAFE_DELETE(__pOverlayRegion);
+}
+
+void
+FaceTrackerForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList *pArgs)
+{
+ UiApp* pApp = UiApp::GetInstance();
+ if(pApp->GetAppUiState() != APP_UI_STATE_FOREGROUND)
+ {
+ return;
+ }
+
+ if (__isCameraOn == true)
+ {
+ __pCanvas->SetBackgroundColor(0x0);
+ __pCanvas->Clear();
+ Rectangle faceRect = __pFaceData->GetRectangle();
+ if(__pFaceData->GetFaceDetected())
+ {
+ __pCanvas->DrawRectangle(faceRect);
+ __pCanvas->DrawText(Point(faceRect.x, faceRect.y), Tizen::Base::Integer::ToString(__pFaceData->GetSimilarity()),Tizen::Graphics::Color(0xFF0000FF));
+ }
+ __pCanvas->Show();
+ }
+ else
+ {
+ __pCanvas->Clear();
+ __pCanvas->Show();
+ }
+}
+
+result
+FaceTrackerForm::CheckBatteryLevel(BatteryLevel level)
+{
+ bool isCharging = false;
+ MessageBox msgBox;
+ int modalResult = 0;
+
+ Tizen::System::RuntimeInfo::GetValue(String(L"IsCharging"),isCharging);
+
+ if (isCharging)
+ {
+ return E_SUCCESS;
+ }
+
+ if ((level == BATTERY_EMPTY) || (level == BATTERY_CRITICAL) || (level == BATTERY_LOW))
+ {
+ result r = msgBox.Construct("Warning","Battery Low.\nPlease charge to Use.",MSGBOX_STYLE_OK);
+ TryReturn(r == E_SUCCESS, E_FAILURE, "Failed to construct MessageBox");
+ msgBox.ShowAndWait(modalResult);
+
+ if(modalResult == MSGBOX_RESULT_OK)
+ {
+ Application::GetInstance()->Terminate();
+ }
+
+ return E_FAILURE;
+ }
+
+ return E_SUCCESS;
+}
+
+void
+FaceTrackerForm::OnCameraPreviewed( Tizen::Base::ByteBuffer& previewedData, result r)
+{
+ if(!(__pFaceData->GetThreadCompleted()))
+ {
+ return;
+ }
+ ArrayList *pList = null;
+ ByteBuffer* pBuffer = new (std::nothrow) ByteBuffer();
+ TryReturn(pBuffer != null, , "Failed to create ByteBuffer");
+ pBuffer->Construct(previewedData);
+ TryCatch(r == E_SUCCESS, , "Failed to construct ByteBuffer");
+
+ pList = new (std::nothrow) ArrayList;
+ TryCatch(pList != null, , "Failed to create ArrayList");
+ pList->Construct();
+ TryCatch(r == E_SUCCESS, , "Failed to construct ArrayList");
+ pList->InsertAt (*pBuffer, 0);
+ __pFaceThread->SendUserEvent(RUN_MODE_FACE_DETECTION, pList);
+ return;
+
+CATCH:
+ SAFE_DELETE(pBuffer);
+ SAFE_DELETE(pList);
+}
+
+void
+FaceTrackerForm::OnCameraAutoFocused(bool completeCondition)
+{
+}
+
+void
+FaceTrackerForm::OnCameraCaptured( Tizen::Base::ByteBuffer& capturedData, result r)
+{
+}
+
+void
+FaceTrackerForm::OnCameraErrorOccurred(Tizen::Media::CameraErrorReason r )
+{
+}
+
diff --git a/project/src/FaceTrackerFrame.cpp b/project/src/FaceTrackerFrame.cpp
new file mode 100644
index 0000000..70bd005
--- /dev/null
+++ b/project/src/FaceTrackerFrame.cpp
@@ -0,0 +1,61 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#include "FaceTrackerFrame.h"
+#include "FaceTrackerForm.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+
+FaceTrackerFrame::FaceTrackerFrame(void)
+{
+}
+
+FaceTrackerFrame::~FaceTrackerFrame(void)
+{
+}
+
+result
+FaceTrackerFrame::OnInitializing(void)
+{
+ result r = E_SUCCESS;
+
+ // Create a form
+ FaceTrackerForm* pFaceTrackerForm = new (std::nothrow) FaceTrackerForm();
+ TryReturn(pFaceTrackerForm != null, E_FAILURE, "Failed to create FaceTrackerForm");
+ pFaceTrackerForm->Initialize();
+
+ // Add the form to the frame
+ AddControl(*pFaceTrackerForm);
+
+ // Set the current form
+ SetCurrentForm(*pFaceTrackerForm);
+
+ // Draw the form
+ pFaceTrackerForm->Invalidate(true);
+
+ return r;
+}
+
+result
+FaceTrackerFrame::OnTerminating(void)
+{
+ return E_SUCCESS;
+}
+
+
diff --git a/sample.xml b/sample.xml
new file mode 100644
index 0000000..21824d9
--- /dev/null
+++ b/sample.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<template>
+
+ <slp-property>
+ <property-group>
+ <sample-name>FaceTracker</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>
diff --git a/screenshot.png b/screenshot.png
new file mode 100755
index 0000000..51c4999
--- /dev/null
+++ b/screenshot.png
Binary files differ