├── .classpath ├── .project ├── .settings ├── org.eclipse.core.resources.prefs └── org.eclipse.core.runtime.prefs ├── AndroidManifest.xml ├── LICENSE ├── README.md ├── Screenshots ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.png ├── 5.png ├── 6.png └── 7.png ├── bin ├── AndroidManifest.xml ├── HowOld.apk ├── classes.dex ├── classes │ └── com │ │ └── chenyufengweb │ │ └── howold │ │ ├── BuildConfig.class │ │ ├── FaceActivity$1.class │ │ ├── FaceActivity$2.class │ │ ├── FaceActivity.class │ │ ├── R$attr.class │ │ ├── R$dimen.class │ │ ├── R$drawable.class │ │ ├── R$id.class │ │ ├── R$layout.class │ │ ├── R$menu.class │ │ ├── R$style.class │ │ ├── R$styleable.class │ │ ├── R.class │ │ ├── adapter │ │ └── MyImageAdapter.class │ │ └── utils │ │ ├── FaceppDetect$1.class │ │ ├── FaceppDetect$CallBack.class │ │ └── FaceppDetect.class ├── dexedLibs │ ├── android-support-v4-3a0af9d584078befeb2714727a243ab0.jar │ ├── android-support-v4-642678abf9ce8bf48c2b99135370f427.jar │ ├── faceppsdk-616406adc425c67505033f2c46cfcc03.jar │ └── faceppsdk-c948d4fa4bcb566e8dc989ae9582b61c.jar ├── jarlist.cache ├── res │ └── crunch │ │ ├── drawable-hdpi │ │ ├── app_icon.png │ │ ├── bottom_hint.png │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ │ └── drawable-xxhdpi │ │ ├── female.png │ │ ├── hint.9.png │ │ ├── ic_launcher.png │ │ ├── male.png │ │ └── navi_map_gps_locked.png └── resources.ap_ ├── gen └── com │ └── chenyufengweb │ └── howold │ ├── BuildConfig.java │ └── R.java ├── ic_launcher-web.png ├── libs ├── android-support-v4.jar └── faceppsdk.jar ├── proguard-project.txt ├── project.properties ├── res ├── drawable-hdpi │ ├── app_icon.png │ ├── bottom_hint.png │ └── ic_launcher.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── drawable-xxhdpi │ ├── female.png │ ├── getimage.jpg │ ├── hint.9.png │ ├── ic_launcher.png │ ├── item1.jpg │ ├── item10.jpeg │ ├── item11.jpg │ ├── item12.jpg │ ├── item13.jpg │ ├── item14.jpg │ ├── item15.jpg │ ├── item2.jpg │ ├── item3.jpg │ ├── item4.jpg │ ├── item5.jpg │ ├── item6.jpg │ ├── item7.jpg │ ├── item8.jpg │ ├── item9.jpg │ ├── male.png │ ├── navi_map_gps_locked.png │ ├── pic1.jpeg │ ├── pic2.jpeg │ ├── pic3.jpeg │ ├── pic4.jpeg │ └── startbutton.jpg ├── layout │ └── activity_face.xml ├── menu │ └── face.xml ├── values-v11 │ └── styles.xml ├── values-v14 │ └── styles.xml ├── values-w820dp │ └── dimens.xml └── values │ ├── attr.xml │ ├── dimens.xml │ └── styles.xml └── src └── com └── chenyufengweb └── howold ├── FaceActivity.java ├── adapter └── MyImageAdapter.java └── utils └── FaceppDetect.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | HowOld 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.runtime.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | line.separator=\r\n 3 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 25 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 chenyufeng 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-HowOld 2 |    该项目是基于Face++开发的一款人脸识别App,通过照片可以检测性别、年龄和照片中人物数量。是模仿微软(Microsoft)的HowOld应用开发的类似App。目前已经上线豌豆荚、魅族应用市场、搜狗手机助手和联想市场等多个安卓应用市场。同时我决定开源该项目,为更多的安卓应用开发者或者想进行人脸识别类应用的开发人员提供服务和便利。当然App中还有不少bug和可扩展的功能模块,也希望各位开发者为该项目贡献自己的code力量。大家可以通过点击右上角的fork到自己的Github仓库,也可以点击star实时关注项目进度。 3 | ##1.项目简介 4 |    在前段时间,微软推出的一款产品非常火热,叫做“HowOld”,可以通过你提交的图片检测照片中人物的数量、性别和年龄。但是由于微软推出的只是网页版的产品,并没有在移动端提供App。我的该项目实现的是在Android上高仿微软的“HowOld”,并实现相同功能的Android App。你只要在手机图库中选择照片,并上传检测,几秒钟后就能在原来的照片上绘制出人物数量、性别和年龄的数据。系统主界面如下: 5 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/1.jpg)

6 | ##2.开发指南 7 |    为了项目的开发效率和其他方面的考虑,我并没有使用微软提供的关于人脸识别的接口,而是采用了国内的[Face++](http://www.faceplusplus.com.cn/)来进行开发。Face++有良好的接口,为很多App提供服务,可以方便的进行人脸识别项目的开发。 8 | ###(1)创建应用 9 |    作为开发的需要,建议先去[Face++](http://www.faceplusplus.com.cn/)官网申请一个账号,然后创建一个应用,因为在开发中需要使用API Key和API Secret。创建应用如图: 10 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/4.png)

11 | ###(2)获取API Key和API Secret 12 |    通过步骤(1)后,就能获取API Key和API Secret了。如图所示: 13 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/5.png)

14 | 分别复制到如下代码中: 15 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/6.png)

16 | ###(3)下载SDK 17 |    其实在该项目中,你不需要进行这一步操作,项目中已经集成了Face++的Java(Android)SDK了。如果你想要在其他平台下进行开发,Face++也提供了Python、iOS、PHP等SDK。可以到以下地方进行下载: 18 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/7.png)

19 | ###(4)运行项目 20 |    通过以上步骤,你就可以进行编译运行项目了。期待你的code。 21 | ##3.开发建议 22 |    程序可能还存在bug,你也可以通过Face++提供的其他接口为App增加功能模块,你有的任何创意和想法都可以来实现。希望这个开源项目可以在大家的努力下越来越好,期待你的code。 23 | ##4.运行效果 24 | ###(1)选择图片 25 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/2.jpg)

26 | ###(2)图片检测 27 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/3.jpg)

28 | ##5.技术博客 29 | 我的个人技术博客:[http://blog.csdn.net/chenyufeng1991](http://blog.csdn.net/chenyufeng1991) 。欢迎大家访问! 30 | 31 | #Introduce in English 32 |    This project is an Android app based on Face++ SDK which could detect people face through photos.The app could recognize people's gender,age and the number of people in picture.This app is simulated to Microsoft's web application called HowOld.At present,the app is sold on Peasecod,Meizu App Market,Sougou Assistant.But now,I decide to opensource this project which for many Android App developers and developers who involving in face detect app.At the same time,the project has bugs and lack of some function modules,which I hope developers could contribute your nice code to this app.You could click fork button in the upper right corner to acquire project to you Github repo,or click star button to focus on project progress. 33 | ##1.Project Introduce 34 |    Some time ago,Microsoft launch a popular product called HowOld,which could detect the number of people in photo,people's gender and age.But just a web application without an Android app.My project is an app running on Android OS has the same function with HowOld.You just select a photo in you phone's gallery,then will be draw out quantity,gender and age in former photo.The main interface as following: 35 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/1.jpg)

36 | ##2.Development Guideline 37 |    Consider development efficiency and other factors,I choose the domestic [Face++](http://www.faceplusplus.com.cn/) instead of Microsoft's face recognition interface.Face++ could provide much service,which could simplify the project development. 38 | ###(1)Create Application 39 |    As the need of development,I would like to suggest that create an account in [Face++ official website](http://www.faceplusplus.com.cn/).Then create an application ,bacause we need to use API Key and API Secret.How to create an application as following: 40 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/4.png)

41 | ###(2)Obtain API Key and API Secret 42 |    Through step 1,you can get API Key and API Secret. 43 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/5.png)

44 | Then copy to project : 45 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/6.png)

46 | ###(3)Download SDK 47 |    In fact,you don't need this step operation.Because the project already integrate the Face++ Java(Android)SDK.If you want to develop product in other platform,Face++ also provide Python SDK,iOS SDK,PHP SDK and so on.You can download SDK as following: 48 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/7.png)

49 | ###(4)Run Project 50 |    So far,you could run the app on your smart mobile phone or simulators.Expect your code. 51 | ##3.Development Suggestion 52 |    The program maybe has bugs,you could use other interface about Face++ to add function module.If you have wonderful idea,just coding and pull request.I hope this opensource project will better in everyone's efforts.I expect you code. 53 | ##4.Operation Effect 54 | ###(1)Select Photos 55 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/2.jpg)

56 | ###(2)Photo Detect 57 | ![Alt text](https://github.com/chenyufeng1991/Android-HowOld/raw/master/Screenshots/3.jpg)

58 | ##5.Technology Blog 59 | My personal technology blog:[http://blog.csdn.net/chenyufeng1991](http://blog.csdn.net/chenyufeng1991).Welcome to visit. 60 | -------------------------------------------------------------------------------- /Screenshots/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/Screenshots/1.jpg -------------------------------------------------------------------------------- /Screenshots/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/Screenshots/2.jpg -------------------------------------------------------------------------------- /Screenshots/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/Screenshots/3.jpg -------------------------------------------------------------------------------- /Screenshots/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/Screenshots/4.png -------------------------------------------------------------------------------- /Screenshots/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/Screenshots/5.png -------------------------------------------------------------------------------- /Screenshots/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/Screenshots/6.png -------------------------------------------------------------------------------- /Screenshots/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/Screenshots/7.png -------------------------------------------------------------------------------- /bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 25 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /bin/HowOld.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/HowOld.apk -------------------------------------------------------------------------------- /bin/classes.dex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes.dex -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/BuildConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/BuildConfig.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/FaceActivity$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/FaceActivity$1.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/FaceActivity$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/FaceActivity$2.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/FaceActivity.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/FaceActivity.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/R$attr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/R$attr.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/R$dimen.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/R$dimen.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/R$drawable.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/R$id.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/R$id.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/R$layout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/R$layout.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/R$menu.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/R$menu.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/R$style.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/R$style.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/R$styleable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/R$styleable.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/R.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/adapter/MyImageAdapter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/adapter/MyImageAdapter.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/utils/FaceppDetect$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/utils/FaceppDetect$1.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/utils/FaceppDetect$CallBack.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/utils/FaceppDetect$CallBack.class -------------------------------------------------------------------------------- /bin/classes/com/chenyufengweb/howold/utils/FaceppDetect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/classes/com/chenyufengweb/howold/utils/FaceppDetect.class -------------------------------------------------------------------------------- /bin/dexedLibs/android-support-v4-3a0af9d584078befeb2714727a243ab0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/dexedLibs/android-support-v4-3a0af9d584078befeb2714727a243ab0.jar -------------------------------------------------------------------------------- /bin/dexedLibs/android-support-v4-642678abf9ce8bf48c2b99135370f427.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/dexedLibs/android-support-v4-642678abf9ce8bf48c2b99135370f427.jar -------------------------------------------------------------------------------- /bin/dexedLibs/faceppsdk-616406adc425c67505033f2c46cfcc03.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/dexedLibs/faceppsdk-616406adc425c67505033f2c46cfcc03.jar -------------------------------------------------------------------------------- /bin/dexedLibs/faceppsdk-c948d4fa4bcb566e8dc989ae9582b61c.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/dexedLibs/faceppsdk-c948d4fa4bcb566e8dc989ae9582b61c.jar -------------------------------------------------------------------------------- /bin/jarlist.cache: -------------------------------------------------------------------------------- 1 | # cache for current jar dependency. DO NOT EDIT. 2 | # format is 3 | # Encoding is UTF-8 4 | -------------------------------------------------------------------------------- /bin/res/crunch/drawable-hdpi/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/res/crunch/drawable-hdpi/app_icon.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-hdpi/bottom_hint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/res/crunch/drawable-hdpi/bottom_hint.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/res/crunch/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/res/crunch/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/res/crunch/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-xxhdpi/female.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/res/crunch/drawable-xxhdpi/female.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-xxhdpi/hint.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/res/crunch/drawable-xxhdpi/hint.9.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/res/crunch/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-xxhdpi/male.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/res/crunch/drawable-xxhdpi/male.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-xxhdpi/navi_map_gps_locked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/res/crunch/drawable-xxhdpi/navi_map_gps_locked.png -------------------------------------------------------------------------------- /bin/resources.ap_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/bin/resources.ap_ -------------------------------------------------------------------------------- /gen/com/chenyufengweb/howold/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package com.chenyufengweb.howold; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /gen/com/chenyufengweb/howold/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package com.chenyufengweb.howold; 9 | 10 | public final class R { 11 | public static final class attr { 12 | /**

Must be one of the following constant values.

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
ConstantValueDescription
left_top0
left_bottom1
right_top2
right_bottom3
23 | */ 24 | public static final int position=0x7f010000; 25 | /**

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". 26 | Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), 27 | in (inches), mm (millimeters). 28 |

This may also be a reference to a resource (in the form 29 | "@[package:]type:name") or 30 | theme attribute (in the form 31 | "?[package:][type:]name") 32 | containing a value of this type. 33 | */ 34 | public static final int radius=0x7f010001; 35 | } 36 | public static final class dimen { 37 | /** Default screen margins, per the Android Design guidelines. 38 | 39 | Example customization of dimensions originally defined in res/values/dimens.xml 40 | (such as screen margins) for screens with more than 820dp of available width. This 41 | would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). 42 | 43 | */ 44 | public static final int activity_horizontal_margin=0x7f040000; 45 | public static final int activity_vertical_margin=0x7f040001; 46 | } 47 | public static final class drawable { 48 | public static final int app_icon=0x7f020000; 49 | public static final int bottom_hint=0x7f020001; 50 | public static final int female=0x7f020002; 51 | public static final int getimage=0x7f020003; 52 | public static final int hint=0x7f020004; 53 | public static final int ic_launcher=0x7f020005; 54 | public static final int item1=0x7f020006; 55 | public static final int item10=0x7f020007; 56 | public static final int item11=0x7f020008; 57 | public static final int item12=0x7f020009; 58 | public static final int item13=0x7f02000a; 59 | public static final int item14=0x7f02000b; 60 | public static final int item15=0x7f02000c; 61 | public static final int item2=0x7f02000d; 62 | public static final int item3=0x7f02000e; 63 | public static final int item4=0x7f02000f; 64 | public static final int item5=0x7f020010; 65 | public static final int item6=0x7f020011; 66 | public static final int item7=0x7f020012; 67 | public static final int item8=0x7f020013; 68 | public static final int item9=0x7f020014; 69 | public static final int male=0x7f020015; 70 | public static final int navi_map_gps_locked=0x7f020016; 71 | public static final int pic1=0x7f020017; 72 | public static final int pic2=0x7f020018; 73 | public static final int pic3=0x7f020019; 74 | public static final int pic4=0x7f02001a; 75 | public static final int startbutton=0x7f02001b; 76 | } 77 | public static final class id { 78 | public static final int action_settings=0x7f07000d; 79 | public static final int id_age_gender=0x7f07000c; 80 | public static final int id_backtop=0x7f070005; 81 | public static final int id_detect=0x7f07000a; 82 | public static final int id_gallery=0x7f070007; 83 | public static final int id_getImage=0x7f070009; 84 | public static final int id_imageSwitcher=0x7f070008; 85 | public static final int id_photo=0x7f070006; 86 | public static final int id_waiting=0x7f07000b; 87 | public static final int left_bottom=0x7f070000; 88 | public static final int left_top=0x7f070001; 89 | public static final int right_bottom=0x7f070002; 90 | public static final int right_top=0x7f070003; 91 | public static final int scrollView1=0x7f070004; 92 | } 93 | public static final class layout { 94 | public static final int activity_face=0x7f030000; 95 | } 96 | public static final class menu { 97 | public static final int face=0x7f060000; 98 | } 99 | public static final class style { 100 | /** 101 | Base application theme, dependent on API level. This theme is replaced 102 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 103 | 104 | 105 | 106 | 107 | Theme customizations available in newer API levels can go in 108 | res/values-vXX/styles.xml, while customizations related to 109 | backward-compatibility can go here. 110 | 111 | 112 | 113 | 114 | Base application theme for API 11+. This theme completely replaces 115 | AppBaseTheme from res/values/styles.xml on API 11+ devices. 116 | 117 | API 11 theme customizations can go here. 118 | 119 | Base application theme for API 14+. This theme completely replaces 120 | AppBaseTheme from BOTH res/values/styles.xml and 121 | res/values-v11/styles.xml on API 14+ devices. 122 | 123 | API 14 theme customizations can go here. 124 | */ 125 | public static final int AppBaseTheme=0x7f050000; 126 | /** Application theme. 127 | All customizations that are NOT specific to a particular API-level can go here. 128 | */ 129 | public static final int AppTheme=0x7f050001; 130 | } 131 | public static final class styleable { 132 | /** Attributes that can be used with a ArcMenu. 133 |

Includes the following attributes:

134 | 135 | 136 | 137 | 138 | 139 | 140 |
AttributeDescription
{@link #ArcMenu_position com.chenyufengweb.howold:position}
{@link #ArcMenu_radius com.chenyufengweb.howold:radius}
141 | @see #ArcMenu_position 142 | @see #ArcMenu_radius 143 | */ 144 | public static final int[] ArcMenu = { 145 | 0x7f010000, 0x7f010001 146 | }; 147 | /** 148 |

This symbol is the offset where the {@link com.chenyufengweb.howold.R.attr#position} 149 | attribute's value can be found in the {@link #ArcMenu} array. 150 | 151 | 152 |

Must be one of the following constant values.

153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 |
ConstantValueDescription
left_top0
left_bottom1
right_top2
right_bottom3
163 | @attr name com.chenyufengweb.howold:position 164 | */ 165 | public static final int ArcMenu_position = 0; 166 | /** 167 |

This symbol is the offset where the {@link com.chenyufengweb.howold.R.attr#radius} 168 | attribute's value can be found in the {@link #ArcMenu} array. 169 | 170 | 171 |

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". 172 | Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), 173 | in (inches), mm (millimeters). 174 |

This may also be a reference to a resource (in the form 175 | "@[package:]type:name") or 176 | theme attribute (in the form 177 | "?[package:][type:]name") 178 | containing a value of this type. 179 | @attr name com.chenyufengweb.howold:radius 180 | */ 181 | public static final int ArcMenu_radius = 1; 182 | }; 183 | } 184 | -------------------------------------------------------------------------------- /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/ic_launcher-web.png -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/libs/android-support-v4.jar -------------------------------------------------------------------------------- /libs/faceppsdk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/libs/faceppsdk.jar -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | -------------------------------------------------------------------------------- /res/drawable-hdpi/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-hdpi/app_icon.png -------------------------------------------------------------------------------- /res/drawable-hdpi/bottom_hint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-hdpi/bottom_hint.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/female.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/female.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/getimage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/getimage.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/hint.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/hint.9.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item1.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item10.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item10.jpeg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item11.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item12.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item13.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item14.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item15.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item2.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item3.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item4.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item5.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item6.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item7.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item8.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/item9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/item9.jpg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/male.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/male.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/navi_map_gps_locked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/navi_map_gps_locked.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/pic1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/pic1.jpeg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/pic2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/pic2.jpeg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/pic3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/pic3.jpeg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/pic4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/pic4.jpeg -------------------------------------------------------------------------------- /res/drawable-xxhdpi/startbutton.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenyufeng1991/Android-HowOld/c4f93cc0f0dfc22d115161759e8cf268e83625fc/res/drawable-xxhdpi/startbutton.jpg -------------------------------------------------------------------------------- /res/layout/activity_face.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 17 | 18 | 28 | 29 | 33 | 34 | 38 | 39 | 43 | 44 | 45 | 52 | 53 | 66 | 67 | 77 | 78 | 79 | 80 | 86 | 87 | 91 | 92 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /res/menu/face.xml: -------------------------------------------------------------------------------- 1 |

4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 64dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /res/values/attr.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /src/com/chenyufengweb/howold/FaceActivity.java: -------------------------------------------------------------------------------- 1 | package com.chenyufengweb.howold; 2 | 3 | import org.json.JSONArray; 4 | import org.json.JSONException; 5 | import org.json.JSONObject; 6 | 7 | import com.chenyufengweb.howold.R; 8 | import com.chenyufengweb.howold.adapter.MyImageAdapter; 9 | import com.chenyufengweb.howold.utils.FaceppDetect; 10 | import com.facepp.error.FaceppParseException; 11 | 12 | import android.app.Activity; 13 | import android.content.Context; 14 | import android.content.Intent; 15 | import android.database.Cursor; 16 | import android.graphics.Bitmap; 17 | import android.graphics.BitmapFactory; 18 | import android.graphics.Canvas; 19 | import android.graphics.Color; 20 | import android.graphics.Paint; 21 | import android.net.Uri; 22 | import android.os.Bundle; 23 | import android.os.Handler; 24 | import android.os.Message; 25 | import android.provider.MediaStore; 26 | import android.text.TextUtils; 27 | import android.util.Log; 28 | import android.view.MotionEvent; 29 | import android.view.View; 30 | import android.view.View.OnClickListener; 31 | import android.view.Window; 32 | import android.widget.AdapterView; 33 | import android.widget.Button; 34 | import android.widget.Gallery; 35 | import android.widget.ImageButton; 36 | import android.widget.ImageSwitcher; 37 | import android.widget.ImageView; 38 | import android.widget.ScrollView; 39 | import android.widget.TextView; 40 | import android.widget.ViewFlipper; 41 | import android.widget.AdapterView.OnItemSelectedListener; 42 | 43 | public class FaceActivity extends Activity implements OnClickListener, 44 | OnItemSelectedListener { 45 | 46 | private Context context; 47 | private Gallery gallery; 48 | private ImageSwitcher imageSwitcher; 49 | private ScrollView scrollView; 50 | 51 | private MyImageAdapter myImageAdapter; 52 | 53 | private int[] image = { R.drawable.item1, R.drawable.item2, 54 | R.drawable.item3, R.drawable.item4, R.drawable.item5, 55 | R.drawable.item6, R.drawable.item7, R.drawable.item8, 56 | R.drawable.item9, R.drawable.item10, R.drawable.item11, 57 | R.drawable.item12, R.drawable.item13 }; 58 | 59 | private static final int PICK_CODE = 0X110; 60 | private static final int MSG_SUCCESS = 0X111; 61 | private static final int MSG_ERROR = 0X112; 62 | 63 | private ImageView mPhoto; 64 | private ImageButton mGetImage; 65 | private TextView mDetect; 66 | // private TextView mTip; 67 | private View mWaitting; 68 | 69 | private String mCurrentPhotoStr; 70 | private Bitmap mPhotoImg; 71 | 72 | private Paint mPaint; 73 | 74 | private Handler mHandler = new Handler() { 75 | public void handleMessage(android.os.Message msg) { 76 | 77 | switch (msg.what) { 78 | case MSG_SUCCESS: 79 | mWaitting.setVisibility(View.INVISIBLE); 80 | mDetect.setVisibility(View.INVISIBLE); 81 | JSONObject rs = (JSONObject) msg.obj; 82 | prepareRsBitmap(rs); 83 | mPhoto.setImageBitmap(mPhotoImg); 84 | 85 | break; 86 | 87 | case MSG_ERROR: 88 | mWaitting.setVisibility(View.INVISIBLE); 89 | String errorMsg = (String) msg.obj; 90 | 91 | if (TextUtils.isEmpty(errorMsg)) { 92 | // mTip.setText("ERROR"); 93 | } else { 94 | // mTip.setText(errorMsg); 95 | } 96 | break; 97 | } 98 | } 99 | }; 100 | 101 | @Override 102 | protected void onCreate(Bundle savedInstanceState) { 103 | super.onCreate(savedInstanceState); 104 | requestWindowFeature(Window.FEATURE_NO_TITLE); 105 | setContentView(R.layout.activity_face); 106 | this.context = this; 107 | 108 | initViews(); 109 | 110 | initEvents(); 111 | 112 | mPaint = new Paint(); 113 | 114 | myImageAdapter = new MyImageAdapter(context, image); 115 | gallery.setAdapter(myImageAdapter); 116 | 117 | } 118 | 119 | protected void prepareRsBitmap(JSONObject rs) { 120 | 121 | Bitmap bitmap = Bitmap.createBitmap(mPhotoImg.getWidth(), 122 | mPhotoImg.getHeight(), mPhotoImg.getConfig()); 123 | Canvas canvas = new Canvas(bitmap); 124 | canvas.drawBitmap(mPhotoImg, 0, 0, null); 125 | try { 126 | JSONArray faces = rs.getJSONArray("face"); 127 | int faceCount = faces.length(); 128 | // mTip.setText("find:" + faceCount); 129 | for (int i = 0; i < faceCount; i++) { 130 | // 拿到单独face对象 131 | JSONObject face = faces.getJSONObject(i); 132 | JSONObject posObj = face.getJSONObject("position"); 133 | float x = (float) posObj.getJSONObject("center").getDouble("x"); 134 | float y = (float) posObj.getJSONObject("center").getDouble("y"); 135 | float w = (float) posObj.getDouble("width"); 136 | float h = (float) posObj.getDouble("height"); 137 | 138 | x = x / 100 * bitmap.getWidth(); 139 | y = y / 100 * bitmap.getHeight(); 140 | w = w / 100 * bitmap.getWidth(); 141 | h = h / 100 * bitmap.getHeight(); 142 | 143 | mPaint.setColor(Color.YELLOW); 144 | mPaint.setStrokeWidth(3); 145 | 146 | // 画box 147 | canvas.drawLine(x - w / 2, y - h / 2, x - w / 2, y + h / 2, 148 | mPaint); 149 | canvas.drawLine(x + w / 2, y - h / 2, x + w / 2, y + h / 2, 150 | mPaint); 151 | canvas.drawLine(x - w / 2, y - h / 2, x + w / 2, y - h / 2, 152 | mPaint); 153 | canvas.drawLine(x - w / 2, y + h / 2, x + w / 2, y + h / 2, 154 | mPaint); 155 | // get age and gender 156 | int age = face.getJSONObject("attribute").getJSONObject("age") 157 | .getInt("value"); 158 | Log.i("AGE", age + ""); 159 | String gender = face.getJSONObject("attribute") 160 | .getJSONObject("gender").getString("value"); 161 | 162 | Bitmap ageBitmap = buildAgeBitmap(age, "Male".equals(gender)); 163 | 164 | int ageWidth = ageBitmap.getWidth(); 165 | int ageHeight = ageBitmap.getHeight(); 166 | 167 | if (bitmap.getWidth() < mPhoto.getWidth() 168 | && bitmap.getHeight() < mPhoto.getHeight()) { 169 | 170 | float ratio = Math.max( 171 | bitmap.getWidth() * 1.0f / mPhoto.getWidth(), 172 | bitmap.getHeight() * 1.0f / mPhoto.getHeight()); 173 | 174 | ageBitmap = Bitmap.createScaledBitmap(ageBitmap, 175 | (int) (ageWidth * ratio), 176 | (int) (ageHeight * ratio), false); 177 | } 178 | 179 | canvas.drawBitmap(ageBitmap, x - ageBitmap.getWidth() / 2, y 180 | - h / 2 - ageBitmap.getHeight(), null); 181 | 182 | mPhotoImg = bitmap; 183 | 184 | } 185 | 186 | } catch (JSONException e) { 187 | e.printStackTrace(); 188 | } 189 | 190 | } 191 | 192 | private Bitmap buildAgeBitmap(int age, boolean isMale) { 193 | 194 | TextView tv = (TextView) mWaitting.findViewById(R.id.id_age_gender); 195 | tv.setText(age + ""); 196 | if (isMale) { 197 | tv.setCompoundDrawablesWithIntrinsicBounds(getResources() 198 | .getDrawable(R.drawable.male), null, null, null); 199 | 200 | } else { 201 | tv.setCompoundDrawablesWithIntrinsicBounds(getResources() 202 | .getDrawable(R.drawable.female), null, null, null); 203 | } 204 | tv.setDrawingCacheEnabled(true); 205 | Bitmap bitmap = Bitmap.createBitmap(tv.getDrawingCache()); 206 | tv.destroyDrawingCache(); 207 | 208 | return bitmap; 209 | } 210 | 211 | private void initEvents() { 212 | 213 | mGetImage.setOnClickListener(this); 214 | mDetect.setOnClickListener(this); 215 | gallery.setOnItemSelectedListener(this); 216 | } 217 | 218 | private void initViews() { 219 | mPhoto = (ImageView) findViewById(R.id.id_photo); 220 | mGetImage = (ImageButton) findViewById(R.id.id_getImage); 221 | mDetect = (TextView) findViewById(R.id.id_detect); 222 | // mTip = (TextView) findViewById(R.id.id_tip); 223 | mWaitting = findViewById(R.id.id_waiting); 224 | 225 | gallery = (Gallery) findViewById(R.id.id_gallery); 226 | imageSwitcher = (ImageSwitcher) findViewById(R.id.id_imageSwitcher); 227 | scrollView = (ScrollView) findViewById(R.id.scrollView1); 228 | scrollView.setVerticalScrollBarEnabled(false); 229 | 230 | } 231 | 232 | @Override 233 | public void onClick(View v) { 234 | switch (v.getId()) { 235 | case R.id.id_getImage: 236 | 237 | Intent intent = new Intent(Intent.ACTION_PICK); 238 | intent.setType("image/*"); 239 | startActivityForResult(intent, PICK_CODE); 240 | 241 | break; 242 | 243 | case R.id.id_detect: 244 | mWaitting.setVisibility(View.VISIBLE); 245 | 246 | FaceppDetect.detect(mPhotoImg, new FaceppDetect.CallBack() { 247 | 248 | @Override 249 | public void success(JSONObject result) { 250 | Message msg = Message.obtain(); 251 | msg.what = MSG_SUCCESS; 252 | msg.obj = result; 253 | mHandler.sendMessage(msg); 254 | 255 | } 256 | 257 | @Override 258 | public void error(FaceppParseException exception) { 259 | Message msg = Message.obtain(); 260 | msg.what = MSG_ERROR; 261 | msg.obj = exception.getErrorMessage(); 262 | mHandler.sendMessage(msg); 263 | 264 | } 265 | 266 | }); 267 | 268 | break; 269 | 270 | } 271 | 272 | } 273 | 274 | @Override 275 | protected void onActivityResult(int requestCode, int resultCode, 276 | Intent intent) { 277 | 278 | if (requestCode == PICK_CODE) { 279 | if (intent != null) { 280 | 281 | Uri uri = intent.getData(); 282 | Cursor cursor = getContentResolver().query(uri, null, null, 283 | null, null); 284 | cursor.moveToFirst(); 285 | 286 | int idx = cursor 287 | .getColumnIndex(MediaStore.Images.ImageColumns.DATA); 288 | mCurrentPhotoStr = cursor.getString(idx); 289 | cursor.close(); 290 | 291 | resizePhoto(); 292 | mPhoto.setImageBitmap(mPhotoImg); 293 | // mTip.setText("Click Detect-->"); 294 | mDetect.setVisibility(View.VISIBLE); 295 | } 296 | } 297 | 298 | super.onActivityResult(requestCode, resultCode, intent); 299 | } 300 | 301 | private void resizePhoto() { 302 | BitmapFactory.Options options = new BitmapFactory.Options(); 303 | options.inJustDecodeBounds = true; 304 | 305 | BitmapFactory.decodeFile(mCurrentPhotoStr, options); 306 | 307 | double ratio = Math.max(options.outWidth * 1.0d / 1024f, 308 | options.outHeight * 1.0d / 1024f); 309 | options.inSampleSize = (int) Math.ceil(ratio); 310 | 311 | options.inJustDecodeBounds = false; 312 | 313 | mPhotoImg = BitmapFactory.decodeFile(mCurrentPhotoStr, options); 314 | 315 | } 316 | 317 | @Override 318 | public void onItemSelected(AdapterView parent, View view, int position, 319 | long id) { 320 | imageSwitcher.setBackgroundResource(image[position % 13]); 321 | 322 | } 323 | 324 | @Override 325 | public void onNothingSelected(AdapterView parent) { 326 | // TODO Auto-generated method stub 327 | 328 | } 329 | } 330 | -------------------------------------------------------------------------------- /src/com/chenyufengweb/howold/adapter/MyImageAdapter.java: -------------------------------------------------------------------------------- 1 | package com.chenyufengweb.howold.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.view.ViewGroup.LayoutParams; 7 | import android.widget.BaseAdapter; 8 | import android.widget.Gallery; 9 | import android.widget.ImageView; 10 | import android.widget.ImageView.ScaleType; 11 | 12 | public class MyImageAdapter extends BaseAdapter { 13 | private Context context; 14 | private int[] image; 15 | 16 | public MyImageAdapter(Context context, int[] image) { 17 | super(); 18 | this.context = context; 19 | this.image = image; 20 | } 21 | 22 | @Override 23 | public int getCount() { 24 | return Integer.MAX_VALUE; 25 | } 26 | 27 | @Override 28 | public Object getItem(int position) { 29 | return image[position]; 30 | } 31 | 32 | @Override 33 | public long getItemId(int position) { 34 | return position; 35 | } 36 | 37 | @Override 38 | public View getView(int position, View convertView, ViewGroup parent) { 39 | 40 | ImageView imageView = new ImageView(context); 41 | imageView.setBackgroundResource(image[position % 13]); 42 | imageView.setLayoutParams(new Gallery.LayoutParams(400, 300)); 43 | imageView.setScaleType(ScaleType.FIT_XY); 44 | 45 | return imageView; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/com/chenyufengweb/howold/utils/FaceppDetect.java: -------------------------------------------------------------------------------- 1 | package com.chenyufengweb.howold.utils; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | 5 | import org.json.JSONObject; 6 | 7 | import android.graphics.Bitmap; 8 | import android.util.Log; 9 | 10 | import com.facepp.error.FaceppParseException; 11 | import com.facepp.http.HttpRequests; 12 | import com.facepp.http.PostParameters; 13 | 14 | public class FaceppDetect { 15 | 16 | public static final String KEY = "82f0b4f1514a5973d2c083fe45b60d26"; 17 | public static final String SECRET = "lbS-dE4hVejE7AmtOpCRcZ7bbvYSozaO"; 18 | 19 | public interface CallBack { 20 | void success(JSONObject result); 21 | 22 | void error(FaceppParseException exception); 23 | } 24 | 25 | public static void detect(final Bitmap bm, final CallBack callBack) { 26 | new Thread(new Runnable() { 27 | 28 | @Override 29 | public void run() { 30 | // request 31 | 32 | try { 33 | HttpRequests requests = new HttpRequests(KEY, SECRET, true, 34 | true); 35 | Bitmap bmSmall = Bitmap.createBitmap(bm, 0, 0, 36 | bm.getWidth(), bm.getHeight()); 37 | ByteArrayOutputStream stream = new ByteArrayOutputStream(); 38 | bmSmall.compress(Bitmap.CompressFormat.JPEG, 100, stream); 39 | 40 | byte[] arrays = stream.toByteArray(); 41 | 42 | PostParameters params = new PostParameters(); 43 | params.setImg(arrays); 44 | JSONObject jsonObject = requests.detectionDetect(params); 45 | 46 | // Log 47 | Log.i("TAG", jsonObject.toString()); 48 | 49 | if (callBack != null) { 50 | callBack.success(jsonObject); 51 | } 52 | } catch (FaceppParseException e) { 53 | e.printStackTrace(); 54 | if (callBack != null) { 55 | callBack.error(e); 56 | } 57 | } 58 | 59 | } 60 | }).start(); 61 | 62 | } 63 | 64 | } 65 | --------------------------------------------------------------------------------