--- /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> FaceRecognizer </SampleName>
+ <SampleVersion>1.0</SampleVersion>
+ <Preview>screenshot.png</Preview>
+ <Description>The FaceRecognizer sample application demonstrates how you can enable your device to recognize facial features, and compare and find similarities between 2 faces.
+ </Description>
+</Overview>
--- /dev/null
+//
+// 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_DETECTION_FORM_H_
+#define _FACE_DETECTION_FORM_H_
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FIo.h>
+#include <FUi.h>
+#include <FUix.h>
+#include <FGraphics.h>
+#include <FMedia.h>
+
+#include "Info.h"
+
+class FaceDetectionForm
+ : public Tizen::Ui::Controls::Form
+ , public Tizen::Ui::IActionEventListener
+ , public Tizen::Ui::Controls::IFormBackEventListener
+
+{
+public:
+ FaceDetectionForm(void);
+ virtual ~FaceDetectionForm(void);
+
+ virtual result OnInitializing(void);
+ virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+ virtual result OnDraw(void);
+
+ Tizen::Base::ByteBuffer* LoadImageN(Tizen::Base::String FileName, int& nWidth, int& nHeight);
+ result DrawImage(const Tizen::Graphics::Bitmap* pBitmap);
+ result DrawFaceDetectArea(const Info* pInfo);
+ Tizen::Base::Collection::IList* GetFaceDetectAreaN(const Info* pInfo);
+
+ void DoRecognizing(void);
+ bool FaceRecognize(Tizen::Base::Collection::IList* pFaceDetectList1, Tizen::Base::Collection::IList* pFaceDetectList2);
+ void DoFaceSimilarity(void);
+ int GetSimilarity(Tizen::Base::Collection::IList* pFaceDetectList1, Tizen::Base::Collection::IList* pFaceDetectList2);
+ void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
+
+protected:
+ static const int ID_BUTTON = 101;
+ static const int ID_BUTTON2 = 102;
+
+private:
+ double __percent;
+
+ Tizen::Ui::Controls::Button* __pButton;
+ Tizen::Ui::Controls::Button* __pButton2;
+ Tizen::Ui::Controls::ScrollPanel* __pPanel;
+ Tizen::Graphics::Canvas* __pCanvas;
+ Info* __pPicture;
+
+ Tizen::Base::Collection::ArrayListT< Info >* __pInfoList;
+};
+
+#endif // _FACE_DETECTION_FORM_H_
--- /dev/null
+//
+// 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_RECOGNIZER_H__
+#define __FACE_RECOGNIZER_H__
+
+#include <FApp.h>
+#include <FBase.h>
+#include <FGraphics.h>
+#include <FIo.h>
+#include <FSystem.h>
+#include <FUi.h>
+
+//[FaceRecognizer] application must inherit from Application class
+//which provides basic features necessary to define an application.
+class FaceRecognizer
+ : public Tizen::App::Application
+ , public Tizen::System::IScreenEventListener
+{
+public:
+ //[FaceRecognizer] application must have a factory method that creates an instance of itself.
+ static Tizen::App::Application* CreateInstance(void);
+
+ FaceRecognizer(void);
+ ~FaceRecognizer(void);
+
+ //Called when the application is initializing.
+ bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry);
+
+ //Called when the application is terminating.
+ bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false);
+
+ //Called when the application's frame moves to the top of the screen.
+ void OnForeground(void);
+
+ //Called when this application'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 application 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);
+};
+
+#endif
--- /dev/null
+//
+// 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 _INFO_H_
+#define _INFO_H_
+
+#include <FBase.h>
+#include <FGraphics.h>
+#include <FMedia.h>
+#include <FBaseObject.h>
+#include <FBaseColIComparer.h>
+#include <FUix.h>
+
+class Info
+ : public Tizen::Base::Object
+{
+public:
+ Info(void);
+ Info(Tizen::Base::String fileName, Tizen::Base::String info);
+ Info(const Info& ob);
+ virtual ~Info(void);
+
+ Tizen::Base::String GetFileName(void) const;
+ Tizen::Base::String GetInfo(void) const;
+ const Tizen::Graphics::Bitmap* GetBitmap(void) const;
+ const Tizen::Base::ByteBuffer* GetByteBuffer(void) const;
+ int GetWidth(void) const;
+ int GetHeight(void) const;
+ Tizen::Graphics::BitmapPixelFormat GetPixelFormat(void) const;
+ int GetMatchingPercent(void) const;
+ Tizen::Base::Collection::IList* GetFaceFeatures(void);
+ Tizen::Uix::Vision::EyeState GetEyeState(void) const;
+ Tizen::Uix::Vision::FacialExpression GetFacialExpression(void) const;
+
+ void SetFileName(const Tizen::Base::String fileName);
+ void SetInfo(const Tizen::Base::String info);
+ void SetByteBuffer(Tizen::Base::ByteBuffer* byteBuffer, int width, int height, Tizen::Graphics::BitmapPixelFormat format);
+ void SetMatchingPercent(int percent);
+ void SetFaceFeatures(Tizen::Base::Collection::IList* pFeatures);
+ void SetEyeState(Tizen::Uix::Vision::EyeState eyeState);
+ void SetFacialExpression(Tizen::Uix::Vision::FacialExpression facialExpression);
+
+ bool operator <(const Info& rhs) const;
+ bool operator >(const Info& rhs) const;
+ bool operator ==(const Info& rhs) const;
+ bool operator !=(const Info& rhs) const;
+ Info& operator =(const Info& rhs);
+ bool operator ==(const Tizen::Base::String& fileName);
+ bool operator <(const Tizen::Base::String& ob) const;
+ bool operator >(const Tizen::Base::String& ob) const;
+
+private:
+ Tizen::Graphics::Bitmap* __pBitmap;
+ Tizen::Base::ByteBuffer* __pByteBuffer;
+ int __width;
+ int __height;
+ Tizen::Graphics::BitmapPixelFormat __pixelFormat;
+ int __matchingPercent;
+ Tizen::Base::Collection::IList* __pFaceFeatures;
+ Tizen::Uix::Vision::EyeState __eyeState;
+ Tizen::Uix::Vision::FacialExpression __facialExpression;
+ Tizen::Base::String __fileName;
+ Tizen::Base::String __info;
+};
+
+#endif // _INFO_H_
--- /dev/null
+//\r
+// Tizen C++ SDK\r
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Flora License, Version 1.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.tizenopensource.org/license\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an AS IS BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+\r
+#ifndef _INFO_COMPARE_H_\r
+#define _INFO_COMPARE_H_\r
+\r
+#include "Info.h"\r
+#include <FBaseComparerT.h>\r
+\r
+class InfoCompare\r
+ : public Tizen::Base::ComparerT<Info>\r
+{\r
+public:\r
+ InfoCompare(void);\r
+ virtual ~InfoCompare(void);\r
+\r
+ void SetCompareOpt(int opt);\r
+ virtual result Compare (const Info &obj1, const Info &obj2, int &cmp) const ;\r
+\r
+ static const int SORT_DES = 0;\r
+ static const int SORT_ASC = 1;\r
+ static const int SORT_BY_STRING = 3;\r
+\r
+private:\r
+ int __sortOpt;\r
+};\r
+\r
+#endif // _INFO_COMPARE_H_\r
--- /dev/null
+<?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>
+ </Privileges>
+ <UiApp Main="True" MenuIconVisible="True" Name="$(projectName)" >
+ <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>
--- /dev/null
+//
+// 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 "FaceDetectionForm.h"
+#include "InfoCompare.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Uix::Vision;
+using namespace Tizen::Graphics;
+using namespace Tizen::Media;
+using namespace Tizen::Base::Collection;
+
+static const BitmapPixelFormat DECODEDFORMAT = BITMAP_PIXEL_FORMAT_RGB565;
+static const int SPACE_X = 10;
+static const int SPACE_Y = 80;
+
+static const int PICTURE_SIZE_M = 400;
+static const int PICTURE_SIZE_L = 500;
+
+static const int SCREEN_W = 480;
+static const int SCREEN_H = 360;
+static const int SCREEN_OFFSET_Y = 0;
+
+static const int LABEL_H = 200;
+static const int LABEL_H_MAX = 250;
+
+static const int FONT_SIZE = 50;
+static const int FONT_SIZE_M = 30;
+static const int FONT_SIZE_S = 25;
+
+static const int TEXT_X = 70;
+static const int TEXT_Y = 620;
+
+static const int MARGIN = 10;
+static const int MARGIN5 = 5;
+static const int COUNT3 = 3;
+
+static const wchar_t* BUTTON1_NAME = L"Recognize";
+static const wchar_t* BUTTON2_NAME = L"Similarity";
+
+static const wchar_t* PICTURE1 = L"sample1.png";
+static const wchar_t* PICTURE2 = L"sample2.png";
+static const wchar_t* PICTURE3 = L"sample3.png";
+static const wchar_t* PICTURE4 = L"sample4.png";
+
+static const wchar_t* PICTURE1_PATH = L"res/sample1.png";
+static const wchar_t* PICTURE2_PATH = L"res/sample2.png";
+static const wchar_t* PICTURE3_PATH = L"res/sample3.png";
+static const wchar_t* PICTURE4_PATH = L"res/sample4.png";
+
+static const wchar_t* PICTURE1_NAME = L"Unknown";
+static const wchar_t* PICTURE2_NAME = L"Christine";
+static const wchar_t* PICTURE3_NAME = L"Stephanie";
+static const wchar_t* PICTURE4_NAME = L"Tina";
+
+static const wchar_t* NO_PICTURE = L"No Picture";
+static const wchar_t* NOT_FOUND = L"Not Found";
+
+
+FaceDetectionForm::FaceDetectionForm(void)
+ : __percent(1.0f)
+ , __pButton(null)
+ , __pButton2(null)
+ , __pPanel(null)
+ , __pCanvas(null)
+ , __pPicture(null)
+ , __pInfoList(null)
+{
+}
+
+FaceDetectionForm::~FaceDetectionForm(void)
+{
+ delete __pCanvas;
+ __pCanvas = null;
+ delete __pPicture;
+ __pPicture = null;
+ delete __pInfoList;
+ __pInfoList = null;
+}
+
+result
+FaceDetectionForm::OnInitializing(void)
+{
+ int width = 0;
+ int height = 0;
+ result r = E_SUCCESS;
+
+ Footer* pFooter = this->GetFooter();
+
+ if(pFooter != null)
+ {
+ pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
+ pFooter->SetBackButton();
+ this->SetFormBackEventListener(this);
+
+ FooterItem footerItemRecognize;
+ footerItemRecognize.Construct(ID_BUTTON);
+ footerItemRecognize.SetText(BUTTON1_NAME);
+ pFooter->AddItem(footerItemRecognize);
+
+ FooterItem footerItemSimilarity;
+ footerItemSimilarity.Construct(ID_BUTTON2);
+ footerItemSimilarity.SetText(BUTTON2_NAME);
+ pFooter->AddItem(footerItemSimilarity);
+
+ pFooter->AddActionEventListener(*this);
+ }
+
+ FaceRecognizer faceRecog;
+ r = faceRecog.Construct();
+ TryReturn(r == E_SUCCESS, E_FAILURE, "Failed to construct FaceRecognizer");
+
+ __pPicture = new (std::nothrow) Info(PICTURE1, PICTURE1_NAME);
+ TryReturn(__pPicture != null, E_FAILURE, "Failed to create info");
+ ByteBuffer* pByteBuffer = LoadImageN(Tizen::App::App::GetInstance()->GetAppRootPath() + PICTURE1_PATH, width, height);
+ __pPicture->SetByteBuffer(pByteBuffer, width, height, DECODEDFORMAT);
+ if (height > PICTURE_SIZE_M - SPACE_X)
+ {
+ __percent = (double) PICTURE_SIZE_M / (double) height;
+ }
+ if (width > PICTURE_SIZE_L)
+ {
+ double temp = (double) PICTURE_SIZE_L / (double) width;
+ if (temp < __percent)
+ {
+ __percent = temp;
+ }
+ }
+
+ IList* pFaceList = faceRecog.ExtractFaceInfoFromStillImageN(*(__pPicture->GetByteBuffer()), Dimension(width, height), __pPicture->GetPixelFormat());
+ if (pFaceList != null)
+ {
+ __pPicture->SetFaceFeatures(pFaceList);
+ pFaceList->RemoveAll(true);
+ delete pFaceList;
+ }
+
+ IMapT< Rectangle, EyeState >* pEyeStateIList = faceRecog.DetectBlinksFromStillImageN(*(__pPicture->GetByteBuffer()), Dimension(width, height), __pPicture->GetPixelFormat());
+ if (pEyeStateIList != null)
+ {
+ IMapEnumeratorT< Rectangle, EyeState >* pMapEnum = pEyeStateIList->GetMapEnumeratorN();
+ if (pMapEnum->MoveNext() == E_SUCCESS)
+ {
+ EyeState eyeState;
+ pMapEnum->GetValue(eyeState);
+ __pPicture->SetEyeState(eyeState);
+ }
+ delete pMapEnum;
+ pEyeStateIList->RemoveAll();
+ delete pEyeStateIList;
+ }
+
+ IMapT< Rectangle, FacialExpression >* pFacialExpressionIList = faceRecog.RecognizeExpressionsFromStillImageN(*(__pPicture->GetByteBuffer()), Dimension(width, height), __pPicture->GetPixelFormat());
+ if (pFacialExpressionIList != null)
+ {
+ IMapEnumeratorT< Tizen::Graphics::Rectangle, FacialExpression >* pMapEnum = pFacialExpressionIList->GetMapEnumeratorN();
+ if (pMapEnum->MoveNext() == E_SUCCESS)
+ {
+ FacialExpression facialExpression;
+ pMapEnum->GetValue(facialExpression);
+ __pPicture->SetFacialExpression(facialExpression);
+ }
+ delete pMapEnum;
+ pFacialExpressionIList->RemoveAll();
+ delete pFacialExpressionIList;
+ }
+
+ __pInfoList = new (std::nothrow) ArrayListT< Info >();
+ TryReturn(__pInfoList != null, E_FAILURE, "Failed to create list");
+ r = __pInfoList->Construct();
+ TryReturn(r == E_SUCCESS, E_FAILURE, "Failed to construct List");
+
+ Info* pInfo = new (std::nothrow) Info(PICTURE2, PICTURE2_NAME);
+ TryReturn(pInfo != null, E_FAILURE, "Failed to create info");
+ pByteBuffer = LoadImageN(Tizen::App::App::GetInstance()->GetAppRootPath() + PICTURE2_PATH, width, height);
+ pInfo->SetByteBuffer(pByteBuffer, width, height, DECODEDFORMAT);
+ pFaceList = faceRecog.ExtractFaceInfoFromStillImageN(*(pInfo->GetByteBuffer()), Dimension(width, height), pInfo->GetPixelFormat());
+ if (pFaceList != null)
+ {
+ pInfo->SetFaceFeatures(pFaceList);
+ pFaceList->RemoveAll(true);
+ delete pFaceList;
+ __pInfoList->Add(*pInfo);
+ delete pInfo;
+ }
+
+ pInfo = new (std::nothrow) Info(PICTURE3, PICTURE3_NAME);
+ TryReturn(pInfo != null, E_FAILURE, "Failed to create info");
+ pByteBuffer = LoadImageN(Tizen::App::App::GetInstance()->GetAppRootPath() + PICTURE3_PATH, width, height);
+ pInfo->SetByteBuffer(pByteBuffer, width, height, DECODEDFORMAT);
+ pFaceList = faceRecog.ExtractFaceInfoFromStillImageN(*(pInfo->GetByteBuffer()), Dimension(width, height), pInfo->GetPixelFormat());
+ if (pFaceList != null)
+ {
+ pInfo->SetFaceFeatures(pFaceList);
+ pFaceList->RemoveAll(true);
+ delete pFaceList;
+ __pInfoList->Add(*pInfo);
+ delete pInfo;
+ }
+
+ pInfo = new (std::nothrow) Info(PICTURE4, PICTURE4_NAME);
+ TryReturn(pInfo != null, E_FAILURE, "Failed to create info");
+ pByteBuffer = LoadImageN(Tizen::App::App::GetInstance()->GetAppRootPath() + PICTURE4_PATH, width, height);
+ pInfo->SetByteBuffer(pByteBuffer, width, height, DECODEDFORMAT);
+ pFaceList = faceRecog.ExtractFaceInfoFromStillImageN(*(pInfo->GetByteBuffer()), Dimension(width, height), pInfo->GetPixelFormat());
+ if (pFaceList != null)
+ {
+ pInfo->SetFaceFeatures(pFaceList);
+ pFaceList->RemoveAll(true);
+ delete pFaceList;
+ __pInfoList->Add(*pInfo);
+ delete pInfo;
+ }
+
+ return E_SUCCESS;
+}
+
+void
+FaceDetectionForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+ result r = E_SUCCESS;
+ switch (actionId)
+ {
+ case ID_BUTTON:
+ if (__pPanel != null)
+ {
+ this->RemoveControl(*__pPanel);
+ }
+ __pPanel = new (std::nothrow) ScrollPanel();
+ TryReturn(__pPanel != null, , "Failed to create panel");
+ r = __pPanel->Construct(Rectangle(0, GetClientAreaBounds().height / 2 - SCREEN_OFFSET_Y, SCREEN_W, SCREEN_H));
+ TryReturn(r == E_SUCCESS, , "Failed to construct panel");
+ AddControl(*__pPanel);
+
+ DoRecognizing();
+ break;
+
+ case ID_BUTTON2:
+ if (__pPanel != null)
+ {
+ this->RemoveControl(*__pPanel);
+ }
+ __pPanel = new (std::nothrow) ScrollPanel();
+ TryReturn(__pPanel != null, , "Failed to create panel");
+ r = __pPanel->Construct(Rectangle(0, GetClientAreaBounds().height / 2 - SCREEN_OFFSET_Y, SCREEN_W, SCREEN_H));
+ TryReturn(r == E_SUCCESS, , "Failed to construct panel");
+ AddControl(*__pPanel);
+
+ DoFaceSimilarity();
+ break;
+
+ default:
+ break;
+ }
+
+ RequestRedraw();
+}
+
+result
+FaceDetectionForm::OnDraw(void)
+{
+ result r = E_SUCCESS;
+
+ __pCanvas = GetCanvasN();
+ __pCanvas->Clear();
+
+ r = DrawImage(__pPicture->GetBitmap());
+ r = DrawFaceDetectArea(__pPicture);
+
+ return r;
+}
+
+ByteBuffer*
+FaceDetectionForm::LoadImageN(String FileName, int& nWidth, int& nHeight)
+{
+ result r = E_SUCCESS;
+
+ Image* pImage = new (std::nothrow) Image();
+ TryReturn(pImage != null, null, "Failed to create Image");
+ r = pImage->Construct();
+ TryReturn(r == E_SUCCESS, null, "Failed to construct Image");
+
+ ByteBuffer* pByteBuffer = null;
+ pByteBuffer = pImage->DecodeToBufferN(FileName, DECODEDFORMAT, nWidth, nHeight);
+
+ delete pImage;
+
+ return pByteBuffer;
+}
+
+result
+FaceDetectionForm::DrawImage(const Bitmap* pBitmap)
+{
+ result r = E_SUCCESS;
+
+ int width = 0;
+ int height = 0;
+ width = pBitmap->GetWidth() * __percent;
+ height = pBitmap->GetHeight() * __percent;
+
+ r = __pCanvas->DrawBitmap(Rectangle(SPACE_X, SPACE_Y, width, height), *pBitmap);
+
+ return r;
+}
+
+result
+FaceDetectionForm::DrawFaceDetectArea(const Info* pInfo)
+{
+ result r = E_SUCCESS;
+
+ Tizen::Base::Collection::IList* pFaceDetectList = GetFaceDetectAreaN(pInfo);
+
+ if (pFaceDetectList == null)
+ {
+ return E_OUT_OF_MEMORY;
+ }
+
+ for (int i = 0; i < pFaceDetectList->GetCount(); i++)
+ {
+ Tizen::Graphics::Rectangle* pRect = (Tizen::Graphics::Rectangle*) pFaceDetectList->GetAt(i);
+
+ Rectangle rect((SPACE_X + pRect->x * __percent), (SPACE_Y + pRect->y * __percent),
+ (pRect->width * __percent),
+ (pRect->height * __percent));
+
+ if (__pCanvas == null || (rect.height <= 0 && rect.width <= 0))
+ {
+ pFaceDetectList->RemoveAll(true);
+ delete pFaceDetectList;
+ return E_INVALID_STATE;
+ }
+
+ __pCanvas->SetLineWidth(COUNT3);
+ r = __pCanvas->DrawRectangle(rect);
+
+ Font font;
+ r = font.Construct(FONT_STYLE_PLAIN | FONT_STYLE_BOLD, FONT_SIZE_M);
+ TryReturn(r == E_SUCCESS, E_FAILURE, "Failed to construct font");
+ __pCanvas->SetFont(font);
+ int xPos = SPACE_X * 2 + pInfo->GetWidth();
+ int yPos = pInfo->GetHeight() / COUNT3;
+ Tizen::Base::String text;
+
+ switch (pInfo->GetEyeState())
+ {
+ case EYE_STATE_BOTH_OPEN:
+ text = L"Eye Open";
+ break;
+
+ case EYE_STATE_BOTH_CLOSED:
+ text = L"Eye Closed";
+ break;
+
+ case EYE_STATE_NONE:
+ break;
+ }
+
+ r = __pCanvas->DrawText(Point(xPos, SPACE_Y + yPos), text);
+
+ switch (pInfo->GetFacialExpression())
+ {
+ case FACIAL_EXPRESSION_NEUTRAL:
+ text = L"Neutral";
+ break;
+
+ case FACIAL_EXPRESSION_ANGRY:
+ text = L"Angry";
+ break;
+
+ case FACIAL_EXPRESSION_HAPPY:
+ text = L"Happy";
+ break;
+
+ case FACIAL_EXPRESSION_SURPRISED:
+ text = L"Surprised";
+ break;
+
+ case FACIAL_EXPRESSION_NONE:
+ break;
+ }
+ r = __pCanvas->DrawText(Point(xPos, SPACE_Y + yPos * 2), text);
+ }
+ pFaceDetectList->RemoveAll(true);
+ delete pFaceDetectList;
+ return r;
+}
+
+Tizen::Base::Collection::IList*
+FaceDetectionForm::GetFaceDetectAreaN(const Info* pInfo)
+{
+ if (pInfo == null)
+ {
+ return null;
+ }
+
+ if (pInfo->GetWidth() > 0 && pInfo->GetHeight() > 0)
+ {
+ //Detect faces
+ FaceDetector faceDetect;
+ result r = faceDetect.Construct();
+ TryReturn(r == E_SUCCESS, null, "Failed to construct FaceDetector");
+ Tizen::Base::Collection::IList* pFaceDetectList = faceDetect.DetectFacesFromStillImageN(*(pInfo->GetByteBuffer()), Dimension(pInfo->GetWidth(), pInfo->GetHeight()), pInfo->GetPixelFormat());
+
+ return pFaceDetectList;
+ }
+
+ return null;
+}
+
+void
+FaceDetectionForm::DoRecognizing()
+{
+ result r = E_SUCCESS;
+ if (__pPicture->GetBitmap() == null)
+ {
+ Font font;
+ r = font.Construct(FONT_STYLE_PLAIN | FONT_STYLE_BOLD, FONT_SIZE);
+ TryReturn(r == E_SUCCESS, , "Failed to construct font");
+
+ String Msg(NO_PICTURE);
+ __pCanvas->SetFont(font);
+ __pCanvas->DrawText(Point(TEXT_X, TEXT_Y), Msg);
+ Draw();
+
+ return;
+ }
+
+ InfoCompare* pInfoComparer = new InfoCompare();
+ TryReturn(pInfoComparer != null, , "Failed to create InfoCompare");
+ pInfoComparer->SetCompareOpt(InfoCompare::SORT_BY_STRING);
+ __pInfoList->Sort(*pInfoComparer);
+ delete pInfoComparer;
+
+ int Y = 0;
+ int labelHeight = LABEL_H;
+ bool IsMatching = false;
+
+ for (int index = 0; index < __pInfoList->GetCount(); index++)
+ {
+ Info* pInfo = new (std::nothrow) Info();
+ TryReturn(pInfo != null, , "Failed to create Info");
+ __pInfoList->GetAt(index, *pInfo);
+ const Bitmap* pBitmap = (static_cast< Info* >(pInfo))->GetBitmap();
+
+ if (pBitmap == null)
+ {
+ continue;
+ }
+ if (FaceRecognize(__pPicture->GetFaceFeatures(), pInfo->GetFaceFeatures()))
+ {
+ Font font;
+ r = font.Construct(FONT_STYLE_PLAIN | FONT_STYLE_BOLD, FONT_SIZE_S);
+ TryReturn(r == E_SUCCESS, , "Failed to construct font");
+
+ __pPanel->SetShowState(true);
+
+ Label* pLabel = new (std::nothrow) Label();
+ if (pLabel == null && pInfo != null)
+ {
+ delete pInfo;
+ return;
+ }
+ Label* pLabe2 = new (std::nothrow) Label();
+ if (pLabe2 == null && pInfo != null)
+ {
+ delete pInfo;
+ return;
+ }
+ r = pLabel->Construct(Rectangle(0, Y, GetClientAreaBounds().width / 2, labelHeight), pInfo->GetInfo());
+ if (r != E_SUCCESS)
+ {
+ delete pInfo;
+ return;
+ }
+ pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
+ pLabel->SetTextConfig(FONT_SIZE_M, LABEL_TEXT_STYLE_NORMAL);
+
+ r = pLabe2->Construct(Rectangle(GetClientAreaBounds().width / 2 + MARGIN, Y, GetClientAreaBounds().width / 2 - MARGIN * 2, labelHeight - COUNT3), L" ");
+ if (r != E_SUCCESS)
+ {
+ delete pInfo;
+ return;
+ }
+ Bitmap* pBackBitmap = new (std::nothrow) Bitmap();
+ if (pBackBitmap == null && pInfo != null)
+ {
+ delete pInfo;
+ return;
+ }
+ int width = pBitmap->GetWidth();
+ int height = pBitmap->GetHeight();
+
+ r = pBackBitmap->Construct(*pBitmap, Rectangle(0, 0, width, height));
+ if (r != E_SUCCESS)
+ {
+ delete pInfo;
+ return;
+ }
+
+ if (pBackBitmap != null)
+ {
+ //Bitmap scale change
+ double percent = 1;
+ if (height > labelHeight - MARGIN5)
+ {
+
+ percent = (double) (labelHeight - MARGIN5) / (double) height;
+ height = height* percent;
+
+ int temp = width* percent;
+ if (temp > LABEL_H_MAX)
+ {
+ percent = (double) LABEL_H_MAX / (double) width;
+ height = height* percent;
+ width = width* percent;
+ }
+ else
+ {
+ width = temp;
+ }
+ }
+
+ pBackBitmap->Scale(Dimension(width, height));
+ pLabe2->SetBackgroundBitmap(*pBackBitmap);
+ delete pBackBitmap;
+ }
+
+ __pPanel->AddControl(*pLabel);
+ __pPanel->AddControl(*pLabe2);
+
+ __pPanel->RequestRedraw(true);
+
+ Y += labelHeight;
+ IsMatching = true;
+ }
+ if (pInfo != null)
+ {
+ delete pInfo;
+ }
+ }
+
+ if (!IsMatching)
+ {
+ Font font;
+ r = font.Construct(FONT_STYLE_PLAIN | FONT_STYLE_BOLD, FONT_SIZE);
+ TryReturn(r == E_SUCCESS, , "Failed to construct font");
+
+ String Msg(NOT_FOUND);
+ __pCanvas->SetFont(font);
+ __pCanvas->DrawText(Point(TEXT_X, TEXT_Y), Msg);
+ Draw();
+
+ return;
+ }
+}
+
+bool
+FaceDetectionForm::FaceRecognize(Tizen::Base::Collection::IList* pFaceDetectList1, Tizen::Base::Collection::IList* pFaceDetectList2)
+{
+ FaceRecognizer faceRecog;
+ result r = faceRecog.Construct();
+ TryReturn(r == E_SUCCESS, false, "Failed to construct FaceRecognizer");
+
+ if (pFaceDetectList1 == null || pFaceDetectList2 == null)
+ {
+ return false;
+ }
+
+ for (int i = 0; i < pFaceDetectList1->GetCount(); i++)
+ {
+ FaceRecognitionInfo* pFInfo1 = (Tizen::Uix::Vision::FaceRecognitionInfo*) pFaceDetectList1->GetAt(i);
+
+ if (pFInfo1 == null)
+ {
+ break;
+ }
+
+ for (int j = 0; j < pFaceDetectList2->GetCount(); j++)
+ {
+ FaceRecognitionInfo* pFInfo2 = (Tizen::Uix::Vision::FaceRecognitionInfo*) (pFaceDetectList2->GetAt(j));
+ if (pFInfo2 == null)
+ {
+ break;
+ }
+ if (faceRecog.IsMatching(*pFInfo1, *pFInfo2))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+void
+FaceDetectionForm::DoFaceSimilarity()
+{
+ result r = E_SUCCESS;
+ if (__pPicture->GetBitmap() == null)
+ {
+ Font font;
+ r = font.Construct(FONT_STYLE_PLAIN | FONT_STYLE_BOLD, FONT_SIZE);
+ TryReturn(r == E_SUCCESS, , "Failed to construct font");
+
+ String Msg(NO_PICTURE);
+ __pCanvas->SetFont(font);
+ __pCanvas->DrawText(Point(TEXT_X, TEXT_Y), Msg);
+ Draw();
+
+ return;
+ }
+
+ int width = 0, height = 0;
+ width = __pPicture->GetBitmap()->GetWidth();
+ height = __pPicture->GetBitmap()->GetHeight();
+
+ if (width <= 0 && height <= 0)
+ {
+ return;
+ }
+
+ for (int index = 0; index < __pInfoList->GetCount(); index++)
+ {
+ Info* pInfo = new (std::nothrow) Info();
+ TryReturn(pInfo != null, , "Failed to create Info");
+ __pInfoList->GetAt(index, *pInfo);
+
+ int similarity = GetSimilarity(__pPicture->GetFaceFeatures(), pInfo->GetFaceFeatures());
+ int before = pInfo->GetMatchingPercent();
+ if (similarity > before)
+ {
+ __pInfoList->RemoveAt(index);
+ pInfo->SetMatchingPercent(similarity);
+ __pInfoList->InsertAt(*pInfo, index);
+ }
+ delete pInfo;
+ }
+
+ InfoCompare* pInfoComparer = new InfoCompare();
+ TryReturn(pInfoComparer != null, , "Failed to create InfoCompare");
+ pInfoComparer->SetCompareOpt(InfoCompare::SORT_DES);
+ __pInfoList->Sort(*pInfoComparer);
+ delete pInfoComparer;
+
+ //draw
+ int Y = 0;
+ int labelHeight = LABEL_H;
+
+ bool IsSimilarity = false;
+
+ for (int index2 = 0; index2 < __pInfoList->GetCount(); index2++)
+ {
+ Info* pInfo = new (std::nothrow) Info();
+ TryReturn(pInfo != null, , "Failed to create Info");
+ __pInfoList->GetAt(index2, *pInfo);
+
+ if (pInfo != null && pInfo->GetMatchingPercent() > 0)
+ {
+ __pPanel->SetShowState(true);
+ Label* pLabel = new (std::nothrow) Label();
+ if (pLabel == null && pInfo != null)
+ {
+ delete pInfo;
+ return;
+ }
+ Label* pLabe2 = new (std::nothrow) Label();
+ if (pLabe2 == null && pInfo != null)
+ {
+ delete pInfo;
+ return;
+ }
+ String temp;
+ temp.Append((int) pInfo->GetMatchingPercent());
+ String labelText = pInfo->GetInfo();
+ labelText += "\n";
+ labelText += temp;
+
+ r = pLabel->Construct(Rectangle(0, Y, GetClientAreaBounds().width / 2, labelHeight), labelText);
+ if (r != E_SUCCESS)
+ {
+ delete pInfo;
+ return;
+ }
+ pLabel->SetTextConfig(FONT_SIZE_M, LABEL_TEXT_STYLE_NORMAL);
+ pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
+
+ r = pLabe2->Construct(Rectangle(GetClientAreaBounds().width / 2 + MARGIN, Y, GetClientAreaBounds().width / 2 - MARGIN * 2, labelHeight - COUNT3), L" ");
+ if (r != E_SUCCESS)
+ {
+ delete pInfo;
+ return;
+ }
+
+ const Bitmap* pBitmap = pInfo->GetBitmap();
+
+ Bitmap* pBackBitmap = new (std::nothrow) Bitmap();
+ if (pBackBitmap == null && pInfo != null)
+ {
+ delete pInfo;
+ return;
+ }
+ int width = pBitmap->GetWidth();
+ int height = pBitmap->GetHeight();
+ r = pBackBitmap->Construct(*pBitmap, Rectangle(0, 0, width, height));
+ if (r != E_SUCCESS)
+ {
+ delete pInfo;
+ return;
+ }
+
+ if (pBackBitmap != null)
+ {
+ //Bitmap scale change
+ double percent = 1;
+ if (height > labelHeight - MARGIN5)
+ {
+ percent = (double) (labelHeight - MARGIN5) / (double) height;
+ height = height* percent;
+ int temp = width* percent;
+ if (temp > LABEL_H_MAX)
+ {
+ percent = (double) LABEL_H_MAX / (double) width;
+ height = height* percent;
+ width = width* percent;
+ }
+ else
+ {
+ width = temp;
+ }
+ }
+
+ pBackBitmap->Scale(Dimension(width, height));
+ pLabe2->SetBackgroundBitmap(*pBackBitmap);
+ delete pBackBitmap;
+ }
+
+ __pPanel->AddControl(*pLabel);
+ __pPanel->AddControl(*pLabe2);
+
+ __pPanel->RequestRedraw(true);
+
+ Y += labelHeight;
+
+ IsSimilarity = true;
+ }
+ if (pInfo != null)
+ {
+ delete pInfo;
+ pInfo = null;
+ }
+ }
+
+ if (!IsSimilarity)
+ {
+ Font font;
+ r = font.Construct(FONT_STYLE_PLAIN | FONT_STYLE_BOLD, FONT_SIZE);
+ TryReturn(r == E_SUCCESS, , "Failed to construct font");
+
+ String Msg(NOT_FOUND);
+ __pCanvas->SetFont(font);
+ __pCanvas->DrawText(Point(TEXT_X, TEXT_Y), Msg);
+ Draw();
+
+ return;
+ }
+}
+
+int
+FaceDetectionForm::GetSimilarity(Tizen::Base::Collection::IList* pFaceDetectList1, Tizen::Base::Collection::IList* pFaceDetectList2)
+{
+ int similarity = 0;
+ int before = 0;
+
+ FaceRecognizer faceRecog;
+ result r = faceRecog.Construct();
+ TryReturn(r == E_SUCCESS, -1, "Failed to construct FaceRecognizer");
+
+ if (pFaceDetectList1 == null || pFaceDetectList2 == null)
+ {
+ return 0;
+ }
+
+ for (int i = 0; i < pFaceDetectList1->GetCount(); i++)
+ {
+ FaceRecognitionInfo* pFInfo1 = (Tizen::Uix::Vision::FaceRecognitionInfo*) pFaceDetectList1->GetAt(i);
+
+ if (pFInfo1 == null)
+ {
+ break;
+ }
+
+ for (int j = 0; j < pFaceDetectList2->GetCount(); j++)
+ {
+ FaceRecognitionInfo* pFInfo2 = (Tizen::Uix::Vision::FaceRecognitionInfo*) (pFaceDetectList2->GetAt(j));
+ if (pFInfo2 != null)
+ {
+ similarity = faceRecog.MeasureSimilarity(*pFInfo1, *pFInfo2);
+
+ if (similarity > before)
+ {
+ before = similarity;
+ }
+ }
+ }
+ }
+
+ return before;
+}
+
+void
+FaceDetectionForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
+{
+ UiApp* pApp = UiApp::GetInstance();
+ AppAssert(pApp);
+ pApp->Terminate();
+}
--- /dev/null
+//
+// 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 "FaceRecognizer.h"
+#include "FaceDetectionForm.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+using namespace Tizen::Io;
+using namespace Tizen::System;
+using namespace Tizen::Text;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+
+FaceRecognizer::FaceRecognizer(void)
+{
+}
+
+FaceRecognizer::~FaceRecognizer(void)
+{
+}
+
+Application*
+FaceRecognizer::CreateInstance(void)
+{
+ return new FaceRecognizer();
+}
+
+bool
+FaceRecognizer::OnAppInitializing(AppRegistry& appRegistry)
+{
+ Frame* pAppFrame = new (std::nothrow) Frame();
+ pAppFrame->Construct();
+ AddFrame(*pAppFrame);
+
+ FaceDetectionForm* pForm = new (std::nothrow) FaceDetectionForm();
+ TryReturn(pForm != null, false, "Failed to create form");
+ result r = pForm->Construct(FORM_STYLE_NORMAL | FORM_STYLE_HEADER | FORM_STYLE_FOOTER | FORM_STYLE_INDICATOR);
+ TryReturn(r == E_SUCCESS, false, "Failed to construct form");
+
+ // Set Header
+ Header* pHeader = pForm->GetHeader();
+ pHeader->SetTitleText(L"FACE RECOGNIZER");
+
+ r = GetAppFrame()->GetFrame()->AddControl(*pForm);
+ TryReturn(r == E_SUCCESS, false, "Failed to attach FormMgr to the frame");
+
+ pForm->Draw();
+
+ return true;
+}
+
+bool
+FaceRecognizer::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
+{
+ return true;
+}
+
+void
+FaceRecognizer::OnForeground(void)
+{
+}
+
+void
+FaceRecognizer::OnBackground(void)
+{
+}
+
+void
+FaceRecognizer::OnLowMemory(void)
+{
+}
+
+void
+FaceRecognizer::OnBatteryLevelChanged(BatteryLevel batteryLevel)
+{
+}
+
+void
+FaceRecognizer::OnScreenOn(void)
+{
+}
+
+void
+FaceRecognizer::OnScreenOff(void)
+{
+}
--- /dev/null
+//
+// 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 "FaceRecognizer.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::Application::Execute(FaceRecognizer::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
--- /dev/null
+//
+// 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 "Info.h"
+
+using namespace Tizen::Uix::Vision;
+using namespace Tizen::Graphics;
+using namespace Tizen::Media;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+Info::Info(void)
+ : __pBitmap(null)
+ , __pByteBuffer(null)
+ , __width(0)
+ , __height(0)
+ , __pixelFormat(BITMAP_PIXEL_FORMAT_ARGB8888)
+ , __matchingPercent(0)
+ , __pFaceFeatures(null)
+ , __eyeState(EYE_STATE_NONE)
+ , __facialExpression(FACIAL_EXPRESSION_NONE)
+{
+}
+
+Info::Info(String fileName, String info)
+ : __pBitmap(null)
+ , __pByteBuffer(null)
+ , __width(0)
+ , __height(0)
+ , __pixelFormat(BITMAP_PIXEL_FORMAT_ARGB8888)
+ , __matchingPercent(0)
+ , __pFaceFeatures(null)
+ , __fileName(fileName)
+ , __info(info)
+{
+}
+
+Info::Info(const Info& rhs)
+ : __pFaceFeatures(null)
+{
+ __fileName = rhs.__fileName;
+ __info = rhs.__info;
+ __matchingPercent = rhs.GetMatchingPercent();
+ __eyeState = rhs.__eyeState;
+ __facialExpression = rhs.__facialExpression;
+
+ if(rhs.__pByteBuffer != null)
+ {
+ __pByteBuffer = new ByteBuffer();
+ TryReturn(__pByteBuffer != null, , "Failed to create ByteBuffer");
+ result r = __pByteBuffer->Construct(*rhs.__pByteBuffer);
+ TryReturn(r == E_SUCCESS, , "Failed to construct ByteBuffer");
+ __width = rhs.__width;
+ __height = rhs.__height;
+ __pixelFormat = rhs.__pixelFormat;
+ }
+
+ if(rhs.__pBitmap != null)
+ {
+ __pBitmap = new Bitmap();
+ TryReturn(__pBitmap != null, , "Failed to create Bitmap");
+ result r = __pBitmap->Construct(*__pByteBuffer, Dimension(__width, __height), __pixelFormat, BUFFER_SCALING_NONE);
+ TryReturn(r == E_SUCCESS, , "Failed to construct Bitmap");
+ }
+
+ if (rhs.__pFaceFeatures != null)
+ {
+ SetFaceFeatures(rhs.__pFaceFeatures);
+ }
+}
+
+Info::~Info(void)
+{
+ delete __pBitmap;
+ delete __pByteBuffer;
+ delete __pFaceFeatures;
+}
+
+String
+Info::GetFileName(void) const
+{
+ return __fileName;
+}
+
+String
+Info::GetInfo(void) const
+{
+ return __info;
+}
+
+const Bitmap*
+Info::GetBitmap(void) const
+{
+ return __pBitmap;
+}
+
+const ByteBuffer*
+Info::GetByteBuffer(void) const
+{
+ return __pByteBuffer;
+}
+
+int
+Info::GetWidth(void) const
+{
+ return __width;
+}
+
+int
+Info::GetHeight(void) const
+{
+ return __height;
+}
+
+BitmapPixelFormat
+Info::GetPixelFormat(void) const
+{
+ return __pixelFormat;
+}
+
+int
+Info::GetMatchingPercent(void) const
+{
+ return __matchingPercent;
+}
+
+Tizen::Uix::Vision::EyeState
+Info::GetEyeState(void) const
+{
+ return __eyeState;
+}
+
+Tizen::Uix::Vision::FacialExpression
+Info::GetFacialExpression(void) const
+{
+ return __facialExpression;
+}
+
+void
+Info::SetFileName(const String fileName)
+{
+ __fileName = fileName;
+}
+
+void
+Info::SetInfo(const String info)
+{
+ __fileName = info;
+}
+
+void
+Info::SetByteBuffer(ByteBuffer* byteBuffer, int width, int height, Tizen::Graphics::BitmapPixelFormat format)
+{
+ __pByteBuffer = byteBuffer;
+ __width = width;
+ __height = height;
+ __pixelFormat = format;
+
+ if (__pBitmap == null)
+ {
+ __pBitmap = new (std::nothrow) Bitmap();
+ TryReturn(__pBitmap != null, , "Failed to create Bitmap");
+
+ }
+ result r = __pBitmap->Construct(*__pByteBuffer, Dimension(__width, __height), __pixelFormat, BUFFER_SCALING_NONE);
+ TryReturn(r == E_SUCCESS, , "Failed to construct Bitmap");
+}
+
+void
+Info::SetMatchingPercent(int percent)
+{
+ __matchingPercent = percent;
+}
+
+Tizen::Base::Collection::IList*
+Info::GetFaceFeatures(void)
+{
+ return __pFaceFeatures;
+}
+
+void
+Info::SetFaceFeatures(Tizen::Base::Collection::IList* pFaceFeatures)
+{
+ delete __pFaceFeatures;
+ TryReturn(pFaceFeatures != null, , "Failed to get face feature list");
+
+ Tizen::Base::Collection::ArrayList* pList = new (std::nothrow) ArrayList();
+ TryReturn(pList != null, , "Failed to create List");
+ result r = pList->Construct();
+ TryReturn(r == E_SUCCESS, , "Failed to construct List");
+
+ for (int i = 0; i < pFaceFeatures->GetCount(); i++)
+ {
+ FaceRecognitionInfo* pFInfo = (Tizen::Uix::Vision::FaceRecognitionInfo*) pFaceFeatures->GetAt(i);
+ FaceRecognitionInfo* pFInfoPhoto = new FaceRecognitionInfo();
+ if (pFInfoPhoto == null && pList != null)
+ {
+ delete pList;
+ return;
+ }
+ result r = pFInfoPhoto->Construct(*(pFInfo->GetFaceFeatures()));
+ if (r != E_SUCCESS)
+ {
+ delete pList;
+ return;
+ }
+ pList->Add(*pFInfoPhoto);
+ }
+
+ __pFaceFeatures = pList;
+}
+
+void
+Info::SetEyeState(Tizen::Uix::Vision::EyeState eyeState)
+{
+ __eyeState = eyeState;
+}
+
+void
+Info::SetFacialExpression(Tizen::Uix::Vision::FacialExpression facialExpression)
+{
+ __facialExpression = facialExpression;
+}
+
+bool
+Info::operator <(const Info& rhs) const
+{
+ if (__matchingPercent < rhs.GetMatchingPercent())
+ {
+ return true;
+ }
+ return false;
+}
+
+bool
+Info::operator >(const Info& rhs) const
+{
+ if (__matchingPercent > rhs.GetMatchingPercent())
+ {
+ return true;
+ }
+ return false;
+}
+
+bool
+Info::operator ==(const Info& rhs) const
+{
+ if (__fileName.CompareTo(rhs.__fileName) == 0 &&
+ __info.CompareTo(rhs.__info) == 0 &&
+ __matchingPercent == rhs.__matchingPercent)
+ {
+ return true;
+ }
+ return false;
+}
+
+bool
+Info::operator !=(const Info& rhs) const
+{
+ if (*this == rhs)
+ {
+ return false;
+ }
+ return true;
+}
+
+Info&
+Info::operator =(const Info& rhs)
+{
+ if (this == &rhs)
+ {
+ return *this;
+ }
+
+ __fileName = rhs.__fileName;
+ __info = rhs.__info;
+ __matchingPercent = rhs.GetMatchingPercent();
+ __eyeState = rhs.__eyeState;
+ __facialExpression = rhs.__facialExpression;
+
+ result r = E_SUCCESS;
+ if (rhs.__pByteBuffer != null)
+ {
+ delete __pByteBuffer;
+ __pByteBuffer = new (std::nothrow) ByteBuffer();
+ TryCatch(__pByteBuffer != null, , "Failed to create ByteBuffer");
+ r = __pByteBuffer->Construct(*rhs.__pByteBuffer);
+ TryCatch(r == E_SUCCESS, , "Failed to construct ByteBuffer");
+ __width = rhs.__width;
+ __height = rhs.__height;
+ __pixelFormat = rhs.__pixelFormat;
+ }
+
+ if (rhs.__pBitmap != null)
+ {
+ delete __pBitmap;
+ __pBitmap = new (std::nothrow) Bitmap();
+ TryCatch(__pBitmap != null, , "Failed to create Bitmap");
+ r = __pBitmap->Construct(*__pByteBuffer, Dimension(__width, __height), __pixelFormat, BUFFER_SCALING_NONE);
+ TryCatch(r == E_SUCCESS, , "Failed to construct Bitmap");
+ }
+
+ if (rhs.__pFaceFeatures != null)
+ {
+ SetFaceFeatures(rhs.__pFaceFeatures);
+ }
+
+CATCH:
+ return *this;
+}
+
+
+bool
+Info::operator ==(const String& fileName)
+{
+ if (__fileName.CompareTo(fileName) == 0)
+ {
+ return true;
+ }
+ return false;
+}
+
+bool
+Info::operator <(const String& rhs) const
+{
+ if (__fileName.CompareTo(rhs) < 0)
+ {
+ return true;
+ }
+ return false;
+}
+
+bool
+Info::operator >(const String& rhs) const
+{
+ if (__fileName.CompareTo(rhs) > 0)
+ {
+ return true;
+ }
+ return false;
+}
--- /dev/null
+//\r
+// Tizen C++ SDK\r
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Flora License, Version 1.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.tizenopensource.org/license\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an AS IS BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+\r
+#include "InfoCompare.h"\r
+\r
+InfoCompare::InfoCompare(void)\r
+ : __sortOpt(0)\r
+{\r
+}\r
+\r
+InfoCompare::~InfoCompare(void)\r
+{\r
+}\r
+\r
+void\r
+InfoCompare::SetCompareOpt(int opt)\r
+{\r
+ __sortOpt = opt;\r
+}\r
+\r
+result\r
+InfoCompare::Compare (const Info &obj1, const Info &obj2, int &cmp) const\r
+{\r
+ switch(__sortOpt)\r
+ {\r
+ case SORT_DES:\r
+ {\r
+ if (obj1 > obj2)\r
+ {\r
+ cmp = -1;\r
+ }\r
+ else if (obj1 < obj2)\r
+ {\r
+ cmp = 1;\r
+ }\r
+ else\r
+ {\r
+ cmp = 0;\r
+ }\r
+ }\r
+ break;\r
+\r
+ case SORT_ASC:\r
+ {\r
+ if (obj1 > obj2)\r
+ {\r
+ cmp = 1;\r
+ }\r
+ else if (obj1 < obj2)\r
+ {\r
+ cmp = -1;\r
+ }\r
+ else\r
+ {\r
+ cmp = 0;\r
+ }\r
+ }\r
+ break;\r
+\r
+ case SORT_BY_STRING:\r
+ {\r
+ if (obj1 > obj2.GetFileName())\r
+ {\r
+ cmp = 1;\r
+ }\r
+ else if (obj1 < obj2.GetFileName())\r
+ {\r
+ cmp = -1;\r
+ }\r
+ else\r
+ {\r
+ cmp = 0;\r
+ }\r
+ }\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return E_SUCCESS;\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<template>
+
+ <slp-property>
+ <property-group>
+ <sample-name>FaceRecognizer</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>
+ <element>
+ <simple name="framework" value="osp-compat"/>
+ </element>
+ </complex-array>
+ </process>
+
+</template>