Android上调用百度人脸识别接口

news/2024/10/18 18:26:25/

写了一个简单的调用百度人脸识别在线的JAVA接口,识别率挺高的,但是目前写得还不是很全面,然后打开相册选取图片那一部分,以及工具类代码,是有参考别人写的代码,具体是摘自哪里之前没有保存。

这里贴一些主要的代码。
人脸对比部分:

package ss.demo14;import android.Manifest;
import android.content.ContentUris;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;import com.alibaba.fastjson.JSONObject;import org.apache.log4j.chainsaw.Main;import java.io.File;
import java.text.DecimalFormat;import ss.demo14.mets.CFace;
/**@Author:Swallow*@Date:2018/12/12*/
public class FaceActivity extends AppCompatActivity implements View.OnClickListener {public static final int SELECT_PHOTO1 = 2;public static final int SELECT_PHOTO2 = 3;public static final int TAKE_PHOTO = 4;private ImageView imageViewShow1;private ImageView imageViewShow2;public TextView tv_cmp;String path1, path2,fsres;Button btn1, btn2, btn_make;//private Bitmap orc_bitmap;//新建Handler的对象,在这里接收Message,然后更新TextView控件的内容//这一部分暂时没时间完成@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_face);btn1 = (Button) findViewById(R.id.photo1);btn2 = (Button) findViewById(R.id.photo2);btn_make = (Button) findViewById(R.id.make);btn1.setOnClickListener(this);btn2.setOnClickListener(this);btn_make.setOnClickListener(this);}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.photo1:if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) {ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);}else{openAlbum1();}break;case R.id.photo2:if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) {ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);}else {//opencare();openAlbum2();}break;case R.id.make:if(path1!=null&&path2!=null){sendRequestWithHttpClient();tv_cmp = (TextView)findViewById(R.id.cmp);tv_cmp.setText(fsres);}else{Toast.makeText(this, "图片获取失败", Toast.LENGTH_LONG).show();}break;}}
//开启子线程private void sendRequestWithHttpClient() {new Thread(new Runnable() {@Overridepublic void run() {CFace cf = new CFace();String ss = cf.cface(path1, path2);//获取JSON字符串中的数据String result = JSONObject.parseObject(ss).getString("result");float score = JSONObject.parseObject(result).getFloatValue("score");Log.v("score", "score"+score);//Double so = score;DecimalFormat df = new DecimalFormat("0.00");Double cny = Double.parseDouble(df.format(score));String fsres = face(cny);}}).start();}public String face(double d){//ss=null;if(d>=75.00){fsres = "这两个人是同一个人";}else {fsres = "这两个人不是同一个人";}Log.v("ss",fsres);return fsres;}//按钮一事件public void openAlbum1() {Intent intent = new Intent("android.intent.action.GET_CONTENT");intent.setType("image/*");startActivityForResult(intent, SELECT_PHOTO1);}//按钮二事件public void openAlbum2() {Intent intent = new Intent("android.intent.action.GET_CONTENT");intent.setType("image/*");startActivityForResult(intent, SELECT_PHOTO2);}protected void onActivityResult(int requestCode, int resultCode, Intent data) {super.onActivityResult(requestCode, resultCode, data);switch (requestCode) {//打开相册后返回case SELECT_PHOTO1:if (resultCode == RESULT_OK) {//判断手机系统版本号if (Build.VERSION.SDK_INT > 19) {path1 = handleImgeOnKitKat(data);Bitmap bmap1 = displayImage(path1);//获取图片Bitmap显示到对应的控件上if (bmap1 != null) {imageViewShow1 = (ImageView) findViewById(R.id.iv_show1);imageViewShow1.setImageBitmap(bmap1);}} else {Toast.makeText(this, "图片获取失败", Toast.LENGTH_LONG).show();}}break;case SELECT_PHOTO2:if (resultCode == RESULT_OK) {//判断手机系统版本号if (Build.VERSION.SDK_INT > 19) {//4.4及以上系统使用这个方法处理图片path2 = handleImgeOnKitKat(data);Bitmap bmap2 = displayImage(path2);if (bmap2 != null) {imageViewShow2 = (ImageView) findViewById(R.id.iv_show2);imageViewShow2.setImageBitmap(bmap2);}else {Toast.makeText(this, "图片获取失败", Toast.LENGTH_LONG).show();}}}break;}//API19以上的图片处理方法private String handleImgeOnKitKat(Intent data) {String path=null;Uri uri = data.getData();Log.d("uri=intent.getData :", "" + uri);if (DocumentsContract.isDocumentUri(this, uri)) {String docId = DocumentsContract.getDocumentId(uri);        //数据表里指定的行Log.d("getDocumentId(uri) :", "" + docId);Log.d("uri.getAuthority() :", "" + uri.getAuthority());if ("com.android.providers.media.documents".equals(uri.getAuthority())) {String id = docId.split(":")[1];String selection = MediaStore.Images.Media._ID + "=" + id;path = getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection);} else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())) {Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(docId));path = getImagePath(contentUri, null);}} else if ("content".equalsIgnoreCase(uri.getScheme())) {path = getImagePath(uri, null);}Log.v("path:",path);return path;//displayImage(path);}private Bitmap displayImage(String imagePath) {Bitmap orc_bitmap = null;if (!TextUtils.isEmpty(imagePath)) {orc_bitmap = BitmapFactory.decodeFile(imagePath);//获取图片}return orc_bitmap;}//获取图片的真实路径private String getImagePath(Uri uri, String selection) {String path = null;Cursor cursor = getContentResolver().query(uri, null, selection, null, null);if (cursor != null) {if (cursor.moveToFirst()) {path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));}cursor.close();}return path;}
}

检测人脸信息的部分

package ss.demo14;import android.Manifest;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ContentUris;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import ss.demo14.mets.Find;/**@Author:Swallow*@Date:2018/12/12*/
public class MessgActivity extends AppCompatActivity implements View.OnClickListener{public Button addph,putmes,btn_list;public ImageView ivphoto;public TextView tvnum;public static final int SELECT_PHOTO = 2;public String path=null;private int num;private Bitmap orc_bitmap;private ListView showlv;private List<Map<String, Object>> list = null;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_messg);addph = (Button)findViewById(R.id.add_photo);putmes = (Button)findViewById(R.id.b_check);btn_list = (Button)findViewById(R.id.tolist);addph.setOnClickListener(this);putmes.setOnClickListener(this);btn_list.setOnClickListener(this);}@SuppressLint("WrongViewCast")@Overridepublic void onClick(View v) {switch (v.getId()) {//添加一张照片,获取照片路径显示到控件上面,并且把路径值传给接口case R.id.add_photo://判断权限是否打开if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) {ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);} else {openAlbum();//打开相册}break;case R.id.b_check://如果已经选择图片,传入图片路径值给接口,如果没有选择图片则弹出提示if(path!=null){//获取到的User信息集合list = new ArrayList<Map<String, Object>>();//开启新的子线程new Thread(new Runnable(){@Overridepublic void run() {Find fn = new Find();//String path="/storage/emulated/0/Download/a5.jpg";String mas = fn.findfacemsg(path);//获取JSON字符串中的数据//对取得的JSON数据进行解析,获取人脸列表当中的具体数据String res = JSONObject.parseObject(mas).getString("result");Log.v("res=",res);String facelist = JSONObject.parseObject(res).getString("face_list");Log.v("list",facelist);num = JSONObject.parseObject(res).getInteger("face_num");Log.v("num=",""+num);//获取人脸列表数组JSONArray jsonArray = JSON.parseArray(facelist);//人脸列表当中的数据循环重构到list当中for (int i = 0; i < num; i++){JSONObject jsonObject = jsonArray.getJSONObject(i);//race数组中获取人种String racelist = jsonObject.getString("race");String race = JSONObject.parseObject(racelist).getString("type");//判断人种switch (race){case "yellow":race = "黄种人";break;case "white":race = "白种人";break;case "black":race = "黑种人";break;case "arabs":race = "阿拉伯人";break;}//gender数组中获取性别String genderlist = jsonObject.getString("gender");String gender = JSONObject.parseObject(genderlist).getString("type");//判断性别switch (gender){case "female":gender = "女";break;case "male":gender = "男";break;}int age = jsonObject.getInteger("age");Log.v("listmes:",age+race+gender);//数据传入Map<String, Object> map = new HashMap<String, Object>();map.put("f_num", i+1);map.put("f_sex,", gender);map.put("f_age", age);map.put("f_type", race);list.add(map);}}}).start();}else {Toast.makeText(this, "没有选取图片", Toast.LENGTH_LONG).show();}break;case R.id.tolist://将获取的数据显示到界面当中showlv = (ListView)findViewById(R.id.listView1);//构造listview的适配器SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.faceshow, new String[] { "f_num", "f_sex,", "f_age","f_type" }, new int[] {R.id.f_num, R.id.f_sex, R.id.f_age, R.id.f_type});showlv.setAdapter(adapter);String count = Integer.toString(num);tvnum = (TextView)findViewById(R.id.tv_num);tvnum.setText(count);break;}}private void openAlbum() {Intent intent = new Intent("android.intent.action.GET_CONTENT");intent.setType("image/*");startActivityForResult(intent, SELECT_PHOTO);}@TargetApi(Build.VERSION_CODES.KITKAT)private void handleImgeOnKitKat(Intent data) {//String imagePath = null;Uri uri = data.getData();Log.d("uri=intent.getData :", "" + uri);if (DocumentsContract.isDocumentUri(this, uri)) {String docId = DocumentsContract.getDocumentId(uri);        //数据表里指定的行Log.d("getDocumentId(uri) :", "" + docId);Log.d("uri.getAuthority() :", "" + uri.getAuthority());if ("com.android.providers.media.documents".equals(uri.getAuthority())) {String id = docId.split(":")[1];String selection = MediaStore.Images.Media._ID + "=" + id;path = getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection);} else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())) {Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(docId));path = getImagePath(contentUri, null);}} else if ("content".equalsIgnoreCase(uri.getScheme())) {path = getImagePath(uri, null);}Log.v("path:",path);displayImage(path);}/*** 通过uri和selection来获取真实的图片路径,从相册获取图片时要用*/private String getImagePath(Uri uri, String selection) {//String path = null;Cursor cursor = getContentResolver().query(uri, null, selection, null, null);if (cursor != null) {if (cursor.moveToFirst()) {path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));}cursor.close();}return path;}//显示图片到控件上面private void displayImage(String imagePath) {if (!TextUtils.isEmpty(imagePath)) {orc_bitmap = BitmapFactory.decodeFile(imagePath);//获取图片if (orc_bitmap != null) {ivphoto = (ImageView)findViewById(R.id.imageView);ivphoto.setImageBitmap(orc_bitmap);}} else {Toast.makeText(this, "图片获取失败", Toast.LENGTH_LONG).show();}}protected void onActivityResult(int requestCode, int resultCode, Intent data) {super.onActivityResult(requestCode, resultCode, data);switch (requestCode) {//打开相册后返回case SELECT_PHOTO:if (resultCode == RESULT_OK) {//判断手机系统版本号if (Build.VERSION.SDK_INT > 19) {//4.4及以上系统使用这个方法处理图片handleImgeOnKitKat(data);}}break;}}
}

调用接口的类,其中appID以及Key请自行到百度AI开放平台获取

人脸对比接口

package ss.demo14.mets;import android.util.Log;import com.baidu.aip.face.AipFace;
import com.baidu.aip.face.MatchRequest;
import com.baidu.aip.util.Base64Util;import org.json.JSONException;
import org.json.JSONObject;import java.io.IOException;
import java.util.ArrayList;import ss.demo14.tools.FileUtil;
/**@Author:Swallow*@Date:2018/12/12*/
public class CFace {// public Keys keys = null;public String cface(String path1, String path2) {//初始化百度引擎,传入对应的KeyAipFace client = new AipFace("********", "****", "******");String ss = null;try {//图片格式转换,百度接口要求传入的图片为BASE64格式byte[] bytes1 = FileUtil.readFileByBytes(path1);byte[] bytes2 = FileUtil.readFileByBytes(path2);String image1 = Base64Util.encode(bytes1);String image2 = Base64Util.encode(bytes2);Log.v("img1", image1);Log.v("img2", image2);MatchRequest req1 = new MatchRequest(image1, "BASE64");MatchRequest req2 = new MatchRequest(image2, "BASE64");ArrayList<MatchRequest> requests = new ArrayList<MatchRequest>();requests.add(req1);requests.add(req2);//返回JSON字符串JSONObject res = client.match(requests);ss = res.toString();Log.v("mes", ss);} catch (IOException e) {e.printStackTrace();}return ss;}
}

人脸检测接口

package ss.demo14.mets;import android.util.Log;import com.baidu.aip.face.AipFace;
import com.baidu.aip.face.MatchRequest;
import com.baidu.aip.util.Base64Util;import org.json.JSONException;
import org.json.JSONObject;import java.io.IOException;
import java.util.HashMap;import ss.demo14.tools.FileUtil;
/**@Author:Swallow*@Date:2018/12/12*/
public class Find {public String findfacemsg(String path){AipFace client = new AipFace("********", "********", "********");String mesage = null;try {byte[] bytes = FileUtil.readFileByBytes(path);String image = Base64Util.encode(bytes);//MatchRequest req1 = new MatchRequest(image1, "BASE64");HashMap<String, String> options = new HashMap<String, String>();//获取人脸信息当中的返回值包括年龄,性别,人种//官网可以返回的信息包括age,beauty,expression,faceshape,gender,glasses,landmark,race,quality,facetype信息options.put("face_field", "age,gender,race");options.put("max_face_num", "10");//options.put("face_type", "LIVE");JSONObject res = client.detect(image, "BASE64", options);mesage = res.toString();Log.v("mes", mesage);}catch (IOException e) {e.printStackTrace();}return mesage;}
}

然后是几个会用到的工具类
参考自https://blog.csdn.net/qq_34042417/article/details/82927785

package ss.demo14.tools;import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;/*** 文件读取工具类*/
public class FileUtil {/*** 读取文件内容,作为字符串返回*/public static String readFileAsString(String filePath) throws IOException {File file = new File(filePath);if (!file.exists()) {throw new FileNotFoundException(filePath);} if (file.length() > 1024 * 1024 * 1024) {throw new IOException("File is too large");} StringBuilder sb = new StringBuilder((int) (file.length()));// 创建字节输入流  FileInputStream fis = new FileInputStream(filePath);  // 创建一个长度为10240的Bufferbyte[] bbuf = new byte[10240];  // 用于保存实际读取的字节数  int hasRead = 0;  while ( (hasRead = fis.read(bbuf)) > 0 ) {  sb.append(new String(bbuf, 0, hasRead));  }  fis.close();  return sb.toString();}/*** 根据文件路径读取byte[] 数组*/public static byte[] readFileByBytes(String filePath) throws IOException {File file = new File(filePath);if (!file.exists()) {throw new FileNotFoundException(filePath);} else {ByteArrayOutputStream bos = new ByteArrayOutputStream((int) file.length());BufferedInputStream in = null;try {in = new BufferedInputStream(new FileInputStream(file));short bufSize = 1024;byte[] buffer = new byte[bufSize];int len1;while (-1 != (len1 = in.read(buffer, 0, bufSize))) {bos.write(buffer, 0, len1);}byte[] var7 = bos.toByteArray();return var7;} finally {try {if (in != null) {in.close();}} catch (IOException var14) {var14.printStackTrace();}bos.close();}}}
}
/** Copyright (C) 2017 Baidu, Inc. All Rights Reserved.*/
package ss.demo14.tools;import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;import java.lang.reflect.Type;/*** Json工具类.*/
public class GsonUtils {private static Gson gson = new GsonBuilder().create();public static String toJson(Object value) {return gson.toJson(value);}public static <T> T fromJson(String json, Class<T> classOfT) throws JsonParseException {return gson.fromJson(json, classOfT);}public static <T> T fromJson(String json, Type typeOfT) throws JsonParseException {return (T) gson.fromJson(json, typeOfT);}
}
package ss.demo14.tools;import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;/*** http 工具类*/
public class HttpUtil {public static String post(String requestUrl, String accessToken, String params)throws Exception {String contentType = "application/x-www-form-urlencoded";return HttpUtil.post(requestUrl, accessToken, contentType, params);}public static String post(String requestUrl, String accessToken, String contentType, String params)throws Exception {String encoding = "UTF-8";if (requestUrl.contains("nlp")) {encoding = "GBK";}return HttpUtil.post(requestUrl, accessToken, contentType, params, encoding);}public static String post(String requestUrl, String accessToken, String contentType, String params, String encoding)throws Exception {String url = requestUrl + "?access_token=" + accessToken;return HttpUtil.postGeneralUrl(url, contentType, params, encoding);}public static String postGeneralUrl(String generalUrl, String contentType, String params, String encoding)throws Exception {URL url = new URL(generalUrl);// 打开和URL之间的连接HttpURLConnection connection = (HttpURLConnection) url.openConnection();connection.setRequestMethod("POST");// 设置通用的请求属性connection.setRequestProperty("Content-Type", contentType);connection.setRequestProperty("Connection", "Keep-Alive");connection.setUseCaches(false);connection.setDoOutput(true);connection.setDoInput(true);// 得到请求的输出流对象DataOutputStream out = new DataOutputStream(connection.getOutputStream());out.write(params.getBytes(encoding));out.flush();out.close();// 建立实际的连接connection.connect();// 获取所有响应头字段Map<String, List<String>> headers = connection.getHeaderFields();// 遍历所有的响应头字段for (String key : headers.keySet()) {System.err.println(key + "--->" + headers.get(key));}// 定义 BufferedReader输入流来读取URL的响应BufferedReader in = null;in = new BufferedReader(new InputStreamReader(connection.getInputStream(), encoding));String result = "";String getLine;while ((getLine = in.readLine()) != null) {result += getLine;}in.close();System.err.println("result:" + result);return result;}
}

返回的结果是JSON字符串,解析就可以了。这里我解析了数量、年龄、人种、性别、以及是否为同一个人。

可以在日志里输出。

需要更新到UI界面的话,这部分还没有完成,后面有时间会继续写在这里插入图片描述

在这里插入图片描述

这里我经过几组图片的对比测试,如果是同一个人,不同造型,不同场景下比对结果相似度都在75以上,所以我设定的是相似度为75分以上就判断为同一个人。
如果是同一个人,造型以及场景都差不多,一般都有90分以上

Demo下载地址:
https://download.csdn.net/download/fryan28/10974493


http://www.ppmy.cn/news/836850.html

相关文章

Android 人脸识别了解一下 (中)

转载请注明作者及出处&#xff1a;https://www.jianshu.com/p/b41f64389c21 [25]——Android 人脸识别了解一下 &#xff08;上&#xff09; 在上文中我大致的介绍了官方 Demo 中人脸注册的流程&#xff0c;本文我们接着来看看&#xff0c;在完成了人脸注册之后我们该如何识别…

Adnroid 使用安卓自带的人脸识别API

缺点是精度不高&#xff0c;识别信息很少&#xff0c;只有眼睛的识别 MainActivity.java import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import and…

基于Android平台实现人脸识别

前言 在深度学习出现后&#xff0c;人脸识别技术才真正有了可用性。这是因为之前的机器学习技术中&#xff0c;难以从图片中取出合适的特征值。轮廓&#xff1f;颜色&#xff1f;眼睛&#xff1f;如此多的面孔&#xff0c;且随着年纪、光线、拍摄角度、气色、表情、化妆、佩饰挂…

安卓人脸检测之FaceDetector

最近看到一个APP的头像上传时&#xff0c;如果你设置的图片里面没有人脸&#xff0c;或者有两张以及以上人脸的时候&#xff0c;会提示你图片不符合规范&#xff0c;让你重新设置&#xff0c;这样是为了确保用户的头像是人&#xff01; 然后我就在网上查看了一下资料&#xff0…

人脸识别(识别程序)

系列文章目录 人脸采集 数据训练 代码思路 一、pandas是什么&#xff1f; 示例&#xff1a;pandas 是基于NumPy 的一种工具&#xff0c;该工具是为了解决数据分析任务而创建的。 二、使用步骤 1.引入代码库 import cv2获取人脸识别对象 # 获取人脸识别对象 recognizer …

基于android的人脸识别

把照片分成黑白两种颜色。。。然后扣掉白色的部分。。。 然后判断眼睛是否对称、鼻子是否是一个竖线、口是否眼色有变化 openCV javaCV cn.faceplusplus.com 清华做的人脸识别的网站 package com.njupt.facedetector1;import android.graphics.Bitmap; import android.…

Android使用Face++架构包实现人脸识别

欢迎转载&#xff0c;转载时请标明出处&#xff1a;http://blog.csdn.net/android_for_james/article/details/51016170 今天给大家带来一个通过使用Face来实现人脸识别的功能 我们先去这个Face官网看看&#xff1a;http://www.faceplusplus.com.cn 我们点开案例可以看到众多…

Android 原生的人脸识别Camera+FaceDetector示例

人脸识别google有自带api&#xff0c;Androoid 原生的人脸识别是利用相机的摄像功能和android.media.FaceDetector这个类来实现的 1、android.hardware.camera 1.1 简介 Camera 类用于设置图像捕获设置、开始/停止预览、抓拍图片和检索帧以进行视频编码 Camera的源码 1.2 人…