人脸特征检测内存错误 = 81922,
人脸特征检测格式错误 = 81923,
人脸特征检测参数错误 = 81924,
人脸特征检测结果置信度低 = 81925,
Engine不支持的检测属性 = 86017,
需要检测的属性未初始化 = 86018,
待获取的属性未在process中处理过 = 86019,
PROCESS不支持的检测属性 = 86020,
无效的输入图像 = 86021,
无效的脸部信息2 = 86022,
SDK激活失败_请打开读写权限 = 90113,
SDK已激活 = 90114,
SDK未激活 = 90115,
detectFaceScaleVal不支持 = 90116,
SDK版本不匹配 = 90117,
设备不匹配 = 90118,
唯一标识不匹配 = 90119,
参数为空 = 90120,
活体检测功能已过期 = 90121,
版本不支持 = 90122,
签名错误 = 90123,
数据库插入错误 = 90124,
唯一标识符校验失败 = 90125,
颜色空间不支持 = 90126,
图片宽度或高度不支持 = 90127,
READ_PHONE_STATE权限被拒绝 = 90128,
激活数据被破坏, 请删除激活文件_重新进行激活 = 90129,
无法解析主机地址 = 94209,
无法连接服务器 = 94210,
网络连接超时 = 94211,
网络未知错误 = 94212,
无法连接激活码服务器 = 98305,
服务器系统错误 = 98306,
请求参数错误 = 98307,
激活码正确_且未被使用_但和传入的APPID及APPKEY不匹配 = 98308,
传入的KEY值虽然正确_但此KEY已经被激活 = 98309,
KEY格式不对_一般来说是KEY错误或者未传入KEY值 = 98310
=======================================================================
======================================================================
1.FaceServer.java
…
/**
-
用于预览时注册人脸
-
@param context 上下文对象
-
@param nv21 NV21数据
-
@param width NV21宽度
-
@param height NV21高度
-
@param faceInfo {@link FaceEngine#detectFaces(byte[], int, int, int, List)}获取的人脸信息
-
@param name 保存的名字,若为空则使用时间戳
-
@return 是否注册成功
*/
public boolean registerNv21(Context context, byte[] nv21, int width, int height, FaceInfo faceInfo, String name) {…}
…
/**
-
用于注册照片人脸
-
@param context 上下文对象
-
@param bgr24 bgr24数据
-
@param width bgr24宽度
-
@param height bgr24高度
-
@param name 保存的名字,若为空则使用时间戳
-
@return 是否注册成功
*/
public boolean registerBgr24(Context context, byte[] bgr24, int width, int height, String name) {…}
…
什么是Nv21
NV21 的存储格式是,以4 X 4 图片为例子
占用内存为 4 X 4 X 3 / 2 = 24 个字节
Y Y Y Y
Y Y Y Y
Y Y Y Y
Y Y Y Y
V U V U
V U V U
什么是Bgr24
Bgr24:Bgr24像素格式是一种采用24BPP的sRGB格式。每个颜色通道(蓝色blue, 绿色green, 红色red)各占8BPP(位/像素)。
====================================================================
1.app
的build.gradle
中新增代码:
compile ‘com.guo.android_extend:android-extend:1.0.5’
2.FaceServer.java
中新增代码:
…
public static List faceImgRegisterInfoList;
…
//特征
private static List MyfaceFeatureRegisterInfoList;
//导入手机里的10000个人脸图片
public static List MyimportFaceImgRegisterInfo;
//导入手机里的10000个特征
public static List MyimportFaceFeatureRegisterInfo;
…
//获取图片和姓名的信息
public int getImgAndName(Context context){
synchronized (this){
if (ROOT_PATH == null) {
ROOT_PATH = context.getFilesDir().getAbsolutePath();
}
File imgDir = new File(ROOT_PATH + File.separator + SAVE_IMG_DIR);
if (!imgDir.exists() || !imgDir.isDirectory()) {
return 0;
}
File[] imgFiles = imgDir.listFiles();
if (imgFiles == null || imgFiles.length == 0) {
return 0;
}
faceImgRegisterInfoList = new ArrayList<>();
for (File imgFile : imgFiles) {
faceImgRegisterInfoList.add(new FaceImgRegisterInfo(imgFile.getPath(), getName(imgFile.getName())));
}
return faceImgRegisterInfoList.size();
}
}
private String getName(String path){
int start= path.lastIndexOf(“:”);
int end = path.lastIndexOf(“.”);
return path.substring(start+1,end);
}
3.activity_face_manage.xml
中新增代码:
<com.guo.android_extend.widget.HListView
android:id=“@+id/hlistView”
android:layout_width=“wrap_content”
android:layout_height=“100dp”
android:layout_alignParentBottom=“true”
android:layout_centerHorizontal=“true”
android:scrollbars=“none”
app:dividerHeight=“1dp”
app:listSelector=“@android:drawable/list_selector_background”
android:layout_gravity=“center_horizontal”/>
<TextView
android:id=“@+id/tv_number”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_gravity=“center_horizontal”
android:textSize=“30dp”
android:textColor=“#000000”/>
4.FaceManageActivity.java
中新增代码:
…
private HListView mHListView;
public RegisterViewAdapter mRegisterViewAdapter;
…
mHListView = (HListView) findViewById(R.id.hlistView);
TextView facenum = (TextView) findViewById(R.id.tv_number);
downFile();
mRegisterViewAdapter = new RegisterViewAdapter(FaceManageActivity.this);
mHListView.setAdapter(mRegisterViewAdapter);
…
private void downFile()
{
int faceNum = FaceServer.getInstance().getFaceNumber(this);
if (faceNum == 0) {
showToast(getString(R.string.batch_process_no_face_need_to_delete));
}else {
FaceServer.getInstance().getImgAndName(this);
}
}
…
class Holder {
ExtImageView siv;
TextView tv;
}
class RegisterViewAdapter extends BaseAdapter {
Context mContext;
LayoutInflater mLInflater;
public RegisterViewAdapter(Context c) {
mContext = c;
mLInflater = LayoutInflater.from(mContext);
}
@Override
public int getCount() {
if (FaceServer.faceImgRegisterInfoList==null){
return 0;
}else {
facenum.setText(“注册的人脸数:” + FaceServer.faceImgRegisterInfoList.size() + “个”);
return FaceServer.faceImgRegisterInfoList.size();
}
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder = null;
if (convertView != null)
holder = (Holder) convertView.getTag();
else {
convertView = mLInflater.inflate(R.layout.item_sample, null);
holder = new Holder();
holder.siv = (ExtImageView) convertView.findViewById(R.id.imageView1);
holder.tv = (TextView) convertView.findViewById(R.id.textView1);
convertView.setTag(holder);
}
if (!(FaceServer.faceImgRegisterInfoList == null)){
if (!FaceServer.faceImgRegisterInfoList.isEmpty()){
FaceImgRegisterInfo face = FaceServer.faceImgRegisterInfoList.get(position);
holder.tv.setText(face.getName());
String path = face.getImgpath();
holder.siv.setImageBitmap(BitmapFactory.decodeFile(path));
holder.siv.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
convertView.setWillNotDraw(false);
}
}
return convertView;
}
}
…
====================================================================================
1.FaceManageActivity.java
private static final String ROOT_DIR = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + “arcfacedemo”;
可以发现Environment.getExternalStorageDirectory().getAbsolutePath()
,这路经:/storage/emulated/0/
,但是我想知道这路经到底在哪,去百度找了很多都找不到,看来是说无法查看
这路经可以如何改才能查看
怎么改 先看一下
FaceServer.java
,先查看图片
public boolean registerNv21(Context context, byte[] nv21, int width, int height, FaceInfo faceInfo, String name) {
synchronized (this) {
…
if (ROOT_PATH == null) {
ROOT_PATH = context.getFilesDir().getAbsolutePath();
}
…
//图片存储的文件夹
File imgDir = new File(ROOT_PATH + File.separator + SAVE_IMG_DIR);
if (!imgDir.exists() && !imgDir.mkdirs()) {
Log.e(TAG, “registerNv21: can not create image directory”);
return false;
}
File file = new File(imgDir + File.separator + userName + IMG_SUFFIX);
// 创建一个头像的Bitmap,存放旋转结果图
Bitmap headBmp = getHeadImage(nv21, width, height, faceInfo.getOrient(), cropRect, ArcSoftImageFormat.NV21);
FileOutputStream fosImage = new FileOutputStream(file);
headBmp.compress(Bitmap.CompressFormat.JPEG, 100, fosImage);
fosImage.close();
…
}
}
改的和FaceServer.java
差不多
String path = Environment.getExternalStorageDirectory().getPath();
//SAVE_IMG_DIR = “register” + File.separator + “imgs”;
File MyImgDir = new File(path + File.separator +SAVE_IMG_DIR);
if (!MyImgDir.exists() && !MyImgDir.mkdirs()) {
Log.e(TAG, “已新建文件夹”);
return;
}
for (FaceImgRegisterInfo Mypath : faceImgRegisterInfoList){
File file = new File(MyImgDir + File.separator + Mypath.getName());
Bitmap bitmap = BitmapFactory.decodeFile(Mypath.getImgpath());
try {
FileOutputStream fosImage = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fosImage);
fosImage.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
查看手机里的路经/storage/emulated/0/register/imgs/
如下图:
FaceServer.java
中新增代码 就是图片和特征,完整的代码
//把一个隐藏的文件复制到另一个显示的文件(图片和特征)
public void copy() {
synchronized (this) {
String path = Environment.getExternalStorageDirectory().getPath();
//复制到另一个显示的图片文件
File MyImgDir = new File(path + File.separator + SAVE_IMG_DIR);
if (!MyImgDir.exists() && !MyImgDir.mkdirs()) {
Log.e(TAG, “已新建文件夹”);
} else {
for (FaceImgRegisterInfo Mypath : faceImgRegisterInfoList) {
File file = new File(MyImgDir + File.separator + Mypath.getName());
Bitmap bitmap = BitmapFactory.decodeFile(Mypath.getImgpath());
try {
FileOutputStream fosImage = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fosImage);
fosImage.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
File featureDir = new File(ROOT_PATH + File.separator + SAVE_FEATURE_DIR);
if (!featureDir.exists() || !featureDir.isDirectory()) {
return;
}
File[] featureFiles = featureDir.listFiles();
if (featureFiles == null || featureFiles.length == 0) {
return;
}
MyfaceFeatureRegisterInfoList = new ArrayList<>();
for (File featureFile : featureFiles) {
try {
FileInputStream fis = new FileInputStream(featureFile);
byte[] feature = new byte[FaceFeature.FEATURE_SIZE];
fis.read(feature);
fis.close();
MyfaceFeatureRegisterInfoList.add(new FaceRegisterInfo(feature, featureFile.getName()));
} catch (IOException e) {
e.printStackTrace();
}
}
//复制到另一个显示的特征文件
File MyfeatureDir = new File(path + File.separator + SAVE_FEATURE_DIR);
if (!MyfeatureDir.exists() && !MyfeatureDir.mkdirs()) {
Log.e(TAG, “已新建文件夹”);
return;
}
for (FaceRegisterInfo bytedata : MyfaceFeatureRegisterInfoList) {
File file = new File(MyfeatureDir + File.separator + bytedata.getName());
FileOutputStream fosFeature = null;
try {
fosFeature = new FileOutputStream(file);
fosFeature.write(bytedata.getFeatureData());
fosFeature.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
查看手机里的路经/storage/emulated/0/register/Features/
如下图:
====================================================================================
1.FaceManageActivity.java
中新增代码:
public void BtnImport(View view){
FaceServer.getInstance().MyImport();
FaceServer.getInstance().getImgAndName(this);
mRegisterViewAdapter.notifyDataSetChanged();
}
2.FaceServer.java
中新增代码:
public void MyImport(){
synchronized (this) {
String path = Environment.getExternalStorageDirectory().getPath();
String SAVE_IMG_DIR2 = “register2” + File.separator + “imgs2”;
String SAVE_FEATURE_DIR2 = “register2” + File.separator + “features2”;
File imgfile = new File(path + File.separator + SAVE_IMG_DIR2);
if (!imgfile.exists() || !imgfile.isDirectory()) {
return;
}
File[] imgFiles = imgfile.listFiles();
if (imgFiles == null || imgFiles.length == 0) {
return;
}
File featurefile = new File(path + File.separator + SAVE_FEATURE_DIR2);
if (!featurefile.exists() || !featurefile.isDirectory()) {
return;
}
File[] featureFiles = featurefile.listFiles();
if (featurefile == null || featurefile.length() == 0) {
return;
}
MyimportFaceImgRegisterInfo = new ArrayList<>();
for (File imgFile : imgFiles) {
MyimportFaceImgRegisterInfo.add(new FaceImgRegisterInfo(imgFile.getPath(), imgFile.getName()));
}
MyimportFaceFeatureRegisterInfo = new ArrayList<>();
for (File featureFile : featureFiles) {
FileInputStream fis = null;
try {
fis = new FileInputStream(featureFile);
byte[] feature = new byte[FaceFeature.FEATURE_SIZE];
fis.read(feature);
fis.close();
MyimportFaceFeatureRegisterInfo.add(new FaceRegisterInfo(feature, featureFile.getName()));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
//图片存储的文件夹
File imgDir = new File(ROOT_PATH + File.separator + SAVE_IMG_DIR);
if (!imgDir.exists() && !imgDir.mkdirs()) {
Log.e(TAG, “registerNv21: can not create image directory”);
return;
}
for (FaceImgRegisterInfo img : MyimportFaceImgRegisterInfo) {
File file = new File(imgDir + File.separator + img.getName());
Bitmap bitmap = BitmapFactory.decodeFile(img.getImgpath());
FileOutputStream fosImage = null;
try {
fosImage = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fosImage);
fosImage.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
//特征存储的文件夹
File featureDir = new File(ROOT_PATH + File.separator + SAVE_FEATURE_DIR);
if (!featureDir.exists() && !featureDir.mkdirs()) {
Log.e(TAG, “已建文件夹”);
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(资料价值较高,非无偿)
建议
当我们出去找工作,或者准备找工作的时候,我们一定要想,我面试的目标是什么,我自己的技术栈有哪些,近期能掌握的有哪些,我的哪些短板 ,列出来,有计划的去完成,别看前两天掘金一些大佬在驳来驳去 ,他们的观点是他们的,不要因为他们的观点,膨胀了自己,影响自己的学习节奏。基础很大程度决定你自己技术层次的厚度,你再熟练框架也好,也会比你便宜的,性价比高的替代,很现实的问题但也要有危机意识,当我们年级大了,有哪些亮点,与比我们经历更旺盛的年轻小工程师,竞争。
-
无论你现在水平怎么样一定要 持续学习 没有鸡汤,别人看起来的毫不费力,其实费了很大力,这四个字就是我的建议!!!!!!!!!
-
准备想说怎么样写简历,想象算了,我觉得,技术就是你最好的简历
-
我希望每一个努力生活的it工程师,都会得到自己想要的,因为我们很辛苦,我们应得的。
-
有什么问题想交流,欢迎给我私信,欢迎评论
【附】相关架构及资料
内含往期Android高级架构资料、源码、笔记、视频。高级UI、性能优化、架构师课程、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter全方面的Android进阶实践技术
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门即可获取!
mEmbu-1711609034913)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(资料价值较高,非无偿)
建议
当我们出去找工作,或者准备找工作的时候,我们一定要想,我面试的目标是什么,我自己的技术栈有哪些,近期能掌握的有哪些,我的哪些短板 ,列出来,有计划的去完成,别看前两天掘金一些大佬在驳来驳去 ,他们的观点是他们的,不要因为他们的观点,膨胀了自己,影响自己的学习节奏。基础很大程度决定你自己技术层次的厚度,你再熟练框架也好,也会比你便宜的,性价比高的替代,很现实的问题但也要有危机意识,当我们年级大了,有哪些亮点,与比我们经历更旺盛的年轻小工程师,竞争。
-
无论你现在水平怎么样一定要 持续学习 没有鸡汤,别人看起来的毫不费力,其实费了很大力,这四个字就是我的建议!!!!!!!!!
-
准备想说怎么样写简历,想象算了,我觉得,技术就是你最好的简历
-
我希望每一个努力生活的it工程师,都会得到自己想要的,因为我们很辛苦,我们应得的。
-
有什么问题想交流,欢迎给我私信,欢迎评论
【附】相关架构及资料
[外链图片转存中…(img-pyOh4mvY-1711609034914)]
[外链图片转存中…(img-M7grL8wZ-1711609034914)]
内含往期Android高级架构资料、源码、笔记、视频。高级UI、性能优化、架构师课程、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter全方面的Android进阶实践技术