关键词:
【中文标题】安卓中的人脸识别【英文标题】:Face Recognition in android 【发布时间】:2012-11-07 00:52:40 【问题描述】:我需要在 Android 4.0 的应用中实现人脸识别登录。由于 Android Ice-Cream Sandwich 提供人脸识别解锁功能,是否有任何开放的 SDK 或内置库来实现此功能。到目前为止,我遇到过外部 API,例如 http://www.kooaba.com/ 、 http://developers.face.com/docs/ 。我知道如何检测人脸,但是是否有内置的人脸识别登录支持,或者我必须使用外部 API? 任何帮助将不胜感激。
【问题讨论】:
【参考方案1】:据我所知,Android 4.0 中并没有真正支持人脸识别(只有你知道的人脸检测)。人脸解锁是一个独立的解决方案,不会暴露任何东西。
【讨论】:
【参考方案2】:res/values/strings.xml:
<resources>
<string name="app_name">FaceDetectionExample</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_face_detection_example">FaceDetectionExample</string>
<string name="app_info">Click on the \'Take Picture\' to take a picture using Camera and detect the face(s) in the picture taken.</string>
<string name="take_picture">Take Picture</string>
<string name="detect_face">Detect Face</string>
</resources>
res/layout/detectlayout.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_
android:layout_>
<ImageView
android:layout_
android:layout_
android:id="@+id/image_view"
android:layout_weight="1.0"/>
<Button
android:layout_
android:layout_
android:id="@+id/detect_face"
android:text="@string/detect_face"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_
android:layout_
android:padding="10dip">
<TextView
android:layout_
android:layout_
android:text="@string/app_info"
android:gravity="center_horizontal"
android:layout_weight="1.0"/>
<Button
android:layout_
android:layout_
android:id="@+id/take_picture"
android:layout_margin="5dip"
android:text="@string/take_picture"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.facedetectionexample"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".FaceDetectionExample"
android:label="@string/title_activity_face_detection_example" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
FaceDetectionExample.java
package com.example.facedetectionexample;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.media.FaceDetector;
import android.media.FaceDetector.Face;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class FaceDetectionExample extends Activity
private static final int TAKE_PICTURE_CODE = 100;
private static final int MAX_FACES = 5;
private Bitmap cameraBitmap = null;
@Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((Button)findViewById(R.id.take_picture)).setOnClickListener(btnClick);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
super.onActivityResult(requestCode, resultCode, data);
if(TAKE_PICTURE_CODE == requestCode)
processCameraImage(data);
private void openCamera()
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, TAKE_PICTURE_CODE);
private void processCameraImage(Intent intent)
setContentView(R.layout.detectlayout);
((Button)findViewById(R.id.detect_face)).setOnClickListener(btnClick);
ImageView imageView = (ImageView)findViewById(R.id.image_view);
cameraBitmap = (Bitmap)intent.getExtras().get("data");
imageView.setImageBitmap(cameraBitmap);
private void detectFaces()
if(null != cameraBitmap)
int width = cameraBitmap.getWidth();
int height = cameraBitmap.getHeight();
FaceDetector detector = new FaceDetector(width, height,FaceDetectionExample.MAX_FACES);
Face[] faces = new Face[FaceDetectionExample.MAX_FACES];
Bitmap bitmap565 = Bitmap.createBitmap(width, height, Config.RGB_565);
Paint ditherPaint = new Paint();
Paint drawPaint = new Paint();
ditherPaint.setDither(true);
drawPaint.setColor(Color.RED);
drawPaint.setStyle(Paint.Style.STROKE);
drawPaint.setStrokeWidth(2);
Canvas canvas = new Canvas();
canvas.setBitmap(bitmap565);
canvas.drawBitmap(cameraBitmap, 0, 0, ditherPaint);
int facesFound = detector.findFaces(bitmap565, faces);
PointF midPoint = new PointF();
float eyeDistance = 0.0f;
float confidence = 0.0f;
Log.i("FaceDetector", "Number of faces found: " + facesFound);
if(facesFound > 0)
for(int index=0; index<facesFound; ++index)
faces[index].getMidPoint(midPoint);
eyeDistance = faces[index].eyesDistance();
confidence = faces[index].confidence();
Log.i("FaceDetector",
"Confidence: " + confidence +
", Eye distance: " + eyeDistance +
", Mid Point: (" + midPoint.x + ", " + midPoint.y + ")");
canvas.drawRect((int)midPoint.x - eyeDistance ,
(int)midPoint.y - eyeDistance ,
(int)midPoint.x + eyeDistance,
(int)midPoint.y + eyeDistance, drawPaint);
String filepath = Environment.getExternalStorageDirectory() + "/facedetect" + System.currentTimeMillis() + ".jpg";
try
FileOutputStream fos = new FileOutputStream(filepath);
bitmap565.compress(CompressFormat.JPEG, 90, fos);
fos.flush();
fos.close();
catch (FileNotFoundException e)
e.printStackTrace();
catch (IOException e)
e.printStackTrace();
ImageView imageView = (ImageView)findViewById(R.id.image_view);
imageView.setImageBitmap(bitmap565);
private View.OnClickListener btnClick = new View.OnClickListener()
@Override
public void onClick(View v)
switch(v.getId())
case R.id.take_picture: openCamera(); break;
case R.id.detect_face: detectFaces(); break;
;
还有摇滚!!!!!!!
【讨论】:
答案是相关的,但不是解决方案,您发布的代码是用于人脸检测,而问题明确要求进行人脸识别Java中的人脸识别
】Java中的人脸识别【英文标题】:FacerecognitioninJava【发布时间】:2010-12-0809:37:40【问题描述】:谁能推荐我一个开源的Java人脸识别框架?【问题讨论】:看看这个问题:***.com/questions/953714/face-recognition-library【参考方案1】:您... 查看详情
R中的人脸识别[关闭]
】R中的人脸识别[关闭]【英文标题】:FacerecognitioninR[closed]【发布时间】:2012-02-2416:44:01【问题描述】:有没有用R统计语言编写的人脸识别算法?如果没有,请提供有关我可以从哪里开始将其他算法转换为R的指导。【问题讨论... 查看详情
人脸识别门禁在安防弱电系统中的具体方案
人脸识别门禁系统在办公大楼中的应用在公司安装门禁可以有效地阻止外来的推销人员和其他闲杂人员,保证公司及员工的财产安全,提高企业整体形象。可以通过配套的人脸识别门禁考勤管理软件提高人事部门的工作效率,可... 查看详情
用java写人脸识别算法都有哪些?
...种基于二进制像素点比较的人脸识别算法,它提取了图像中的纹理特征。Haar-like特征:这是一种基于积分图像的人脸识别算法,它检测图像中的边缘特征。ConvolutionalNeuralNetworks(CNNs):这是一种基于卷积神经网络的人脸识别算法,... 查看详情
esp32cam能离线人脸识别吗
...别系统可以检测和识别机场、零售店和火车站等公共场所中的人员。人脸识别系统不仅可以用于安全目的以识别公共场所中的人员,还可以用于办公室和学校中的考勤记录。首先要进行人脸识别,您需要先注册一个人脸。您可以... 查看详情
人脸识别在智慧城市中的应用
...用,其实生活的方方面面面都在展开。那么除了高考校园中的应用之外,人脸识别还在哪些领域大展拳脚呢?智慧金融:刷脸办卡、远程贷款、自主开户、刷脸支付······随着人脸识别技术在金融行业的风起,越来越多的商业... 查看详情
人脸识别在智慧城市中的应用
...用,其实生活的方方面面面都在展开。那么除了高考校园中的应用之外,人脸识别还在哪些领域大展拳脚呢?智慧金融:刷脸办卡、远程贷款、自主开户、刷脸支付······随着人脸识别技术在金融行业的风起,越来越多的商业... 查看详情
java中的英特尔实感人脸识别模块
】java中的英特尔实感人脸识别模块【英文标题】:IntelRealSensefacerecognitionmoduleinjava【发布时间】:2016-04-2020:17:37【问题描述】:我在一个研究团队工作,使用SDK2016R1Intel_rs_sdk_offline_package_r6_8.0.24.6528人脸识别模块和F200摄像头。我... 查看详情
opencv联合dlib视频人脸识别例子(代码片段)
...个实时视频人脸识别功能。原理是利用opencv实时提取视频中的视频流,然后进入人脸检测步骤,步骤类似上篇文章。本篇文章中的程序是在VMware虚拟机下运行的,比较卡,加入人脸识别环节导致视频很不流畅。不... 查看详情
OpenCV Python FAR/FRR 中的人脸识别
】OpenCVPythonFAR/FRR中的人脸识别【英文标题】:FacerecognitioninOpenCVPythonFAR/FRR【发布时间】:2012-08-2505:04:21【问题描述】:如何在OpenCVPython中进行性能测试来检查;获得识别结果所需的时间数据库测试用例的错误接受/错误拒绝率。... 查看详情
人脸识别技术探讨:1:1,1:小n/大n,大姿态识别,活体识别
...我们在后文也会谈及),然后将提取的特征向量与数据库中的特征向量进行比较,以确定他/她是谁。在动态人脸识别中,我们要识别身份的对象为摄像头中一组正在行进的人,或者是视频文件中一组正在行进的人。动态人脸识... 查看详情
008_项目制作拍摄视频篇之_《人脸识别》
...目需求:采用人脸识别算法、AT89C51单片机、蓝牙模块、安卓软件设计一个门禁系统,可以实现人脸识别、面部信息添加、存储、删除;安卓与单片机连接;门禁开关、指示、报警等功能。 具体要求:制作一个简单安卓动态... 查看详情
使用python搭建人脸识别考勤系统
...测更进一步。在人脸检测中,我们只检测人脸在图像中的位置,但在人脸识别中,我们制作了一个可以识别人的系统。“人脸识别是验证或识别图片或视频中的人的挑战。大型科技巨头仍在努力打造更快、更准确的人... 查看详情
人脸识别中的活体检测是啥?
人脸识别的活体检测有什么好处吗?活体检测技术哪个平台好?活体检测一般是通过人脸做出的一些动作,比如抬头、点头、睁眼、闭眼、张嘴、摇头这些,然后再使用人脸关键点定位和追踪技术,验证是否是本人在操作。比如... 查看详情
iOS 人脸识别
...819:21:53【问题描述】:我想开发一个应用程序来识别图像中的人,例如iPhone的照片应用程序。应该使用什么Apple框架来实现这样的功能?谢谢。【问题讨论】:【参考方案1】:愿景应用高性能图像分析和计算机视觉技术来识别人... 查看详情
我想构建一个程序,在该程序中我想识别视频中的人脸选择特定的人脸并将蒙版应用于选定的人脸
】我想构建一个程序,在该程序中我想识别视频中的人脸选择特定的人脸并将蒙版应用于选定的人脸【英文标题】:Iwanttobuildaprograminwhichiwanttorecognizethefacesinvideoselecttheparticularfaceandapplymasktoselectedface【发布时间】:2020-03-2621:24:10... 查看详情
dlib+opencv深度学习人脸识别
...经99.7%以上,这个识别率确实非常高了,但是真实的环境中的准确率有多少呢?我没有这方面的数据,但是可以确信的是真实环 查看详情
如何对齐和裁剪位于子目录中的图像以进行人脸识别?
】如何对齐和裁剪位于子目录中的图像以进行人脸识别?【英文标题】:HowdoIalignandcroptheimageslocatedinsubdirectoriesforfacerecognition?【发布时间】:2020-12-2010:27:30【问题描述】:所以,我有一个文件夹,里面有132个子文件夹,其中人的... 查看详情