当前位置:网站首页>Application of hongruan face recognition
Application of hongruan face recognition
2022-06-30 09:02:00 【Silent Pinocchio】
Application of hongruan face recognition
I have been busy with my work before , There is no time to update the blog , Now we have time , Just share a wave of dry goods with you .
About face recognition , I used Baidu before , The last two have used hongruan , Next, I will introduce the advantages and disadvantages of both . Compared with rainbow soft , Baidu's face recognition needs to rely on the Internet , Longer time consuming , But Baidu's recognition is accurate .
Hongruan's face recognition is applied and developed offline , Because you don't need a network , So its recognition speed is faster . But its recognition is not high , For example, compare two pictures , Compare with Baidu , The similarity may reach 90% above , But the possibility of hongruan will reach 60% about . Baidu's operation is relatively simple . in general , Which one to choose depends on your needs .
Okay , I don't say much nonsense , Next, I will teach you how to use it .
1. The first is to apply on the official website APPKEY, Various keys , Then download jar package , These will not be explained to you one by one . Pay attention to the , To be in app Of gradle Inside plus
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
} this sentence , Otherwise, it may cause so The library cannot be loaded .
2. Next, we need to develop .
Take the function of face detection for example , The first thing you need to
Initialize the engine ,
AFD_FSDKEngine engine1 = new AFD_FSDKEngine();
AFD_FSDKError err = engine1.AFD_FSDK_InitialFaceEngine(Config.APP_ID, Config.FD_KEY, AFD_FSDKEngine.AFD_OPF_0_HIGHER_EXT, 16, 5);`We also need a collection , Used to store the faces we detected ,
List<AFD_FSDKFace> result = new ArrayList<AFD_FSDKFace>();// newly build AFD_FSDKFacejihe, Used to store the recognized face information Then we can carry out face detection , But there are requirements for the selection and format of photos , So we need to format the photos .
Bitmap bitmap1 = decodeImage(path1);//path Is the path of the photo , Select photos first , Turn into bitmap
byte[] data1 = getNv21(bitmap1);// then bitmap Turn into NV21 Format Here's the tool class decodeImage and getNv21 Code for
//getNv21 and decodeImage It is a conversion tool for Photo format
public byte[] getNv21(Bitmap mBitmap) {
byte[] data = new byte[mBitmap.getWidth() * mBitmap.getHeight() * 3 / 2];
ImageConverter convert = new ImageConverter();
convert.initial(mBitmap.getWidth(), mBitmap.getHeight(), ImageConverter.CP_PAF_NV21);
if (convert.convert(mBitmap, data)) {
Log.e("TAG", "convert ok!");
}
convert.destroy();
return data;
}
public static Bitmap decodeImage(String path) {
Bitmap res;
try {
ExifInterface exif = new ExifInterface(path);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
BitmapFactory.Options op = new BitmapFactory.Options();
op.inSampleSize = 1;
op.inJustDecodeBounds = false;
//op.inMutable = true;
res = BitmapFactory.decodeFile(path, op);
//rotate and scale.
Matrix matrix = new Matrix();
if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
matrix.postRotate(90);
} else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) {
matrix.postRotate(180);
} else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
matrix.postRotate(270);
}
Bitmap temp = Bitmap.createBitmap(res, 0, 0, res.getWidth(), res.getHeight(), matrix, true);
Log.d("com.arcsoft", "check target Image:" + temp.getWidth() + "X" + temp.getHeight());
if (!temp.equals(res)) {
res.recycle();
}
return temp;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}After converting the format , The face detection started .
err = engine1.AFD_FSDK_StillImageFaceDetection(data1, bitmap1.getWidth(), bitmap1.getHeight(), AFD_FSDKEngine.CP_PAF_NV21, result);
Log.e("TAG", "getBit: " + result.size());We can view collections result Of size, To determine if a face is detected .
At the end of the code , Be sure to destroy the initialized engine . Otherwise, the program will crash due to memory problems . `
engine1.AFD_FSDK_UninitialFaceEngine();
Face comparison is based on face detection , First detect the face information on a photo , Then compare the face information .
List result = new ArrayList();
That was covered above , The detected face information is stored in result In the collection of ,
Then create two classes to store face point information
AFR_FSDKFace face1 = new AFR_FSDKFace();
AFR_FSDKFace face2 = new AFR_FSDKFace();
Store the point information of the detected face information in face Class
// Two new AFR_FSDKFace class , Save face feature information
AFR_FSDKFace face1 = new AFR_FSDKFace();
AFR_FSDKFace face2 = new AFR_FSDKFace();
// Detection of facial feature information
er = engine_camera.AFR_FSDK_ExtractFRFeature(data_image, bitmap_idcard.getWidth(), bitmap_idcard.getHeight(), AFR_FSDKEngine.CP_PAF_NV21, new Rect(result_image.get(0).getRect()), result_image.get(0).getDegree(), face1);
er = engine_camera.AFR_FSDK_ExtractFRFeature(data, wid, hei, AFR_FSDKEngine.CP_PAF_NV21, new Rect(result_fd.get(0).getRect()), result_fd.get(0).getDegree(), face2);
The similarity information of the final comparison is stored in score in ,
float score_face = score.getScore();
We can get... In this way The similarity information we want , The final data is float Type of .
This is the basic use process of hongruan , I wrote about the use of Baidu's face recognition in the previous article , You can have a look , Comparison , Choose according to your needs .
Finally, if there is anything you don't understand , Welcome to comment and ask questions , You can also add my QQ1064902365 Consultation .
Reprint please indicate the source
边栏推荐
- Explanation on the use of password profiteering cracking tool Hydra
- 【付费推广】常见问题合集,推荐榜单FAQ
- Mmdet line by line code interpretation of positive and negative sample sampler
- Flink sql -- No factory implements ‘org.apache.flink.table.delegation.ExecutorFactory‘.
- Qt通过Url下载文件
- C # listbox how to get the selected content (search many invalid articles)
- Flink 数据偶尔数据积压导致checkpoint失败
- 酒精测试仪方案:酒精测试仪是根据什么原理测酒精溶度?
- Evaluation standard for audio signal quality of intelligent speakers
- Redis design and Implementation (V) | sentinel sentry
猜你喜欢

Enhance the add / delete operation of for loop & iterator delete collection elements

QT connection to Shentong database

Interference source current spectrum test of current probe

Flink Exception -- No ExecutorFactory found to execute the application

Opencv learning notes-day14 drawing of image geometry (rect class rotatedrect class, rectangle drawing rectangle circle drawing circular function line drawing line function ellipse drawing elliptic fu

Bind threads to run on a specific CPU logical kernel

Opencv learning notes -day3 (mat object and creation related operations mat:: clone(), mat:: copyto(), mat:: zeros(), mat:: ones(), scalar()...)

Circuit analysis of current probe

C#访问MongoDB并执行CRUD操作

Flink SQL 自定义 Connector
随机推荐
mysql基础入门 动力节点[老杜]课堂作业
Detectron2 source code reading 4-- registrar construction model
Unity basic lighting model
TiDB v6.0.0 (DMR) :缓存表初试丨TiDB Book Rush
Flink sql -- No factory implements ‘org.apache.flink.table.delegation.ExecutorFactory‘.
QT downloading files through URL
Flink sql -- No factory implements ‘org. apache. flink. table. delegation. ExecutorFactory‘.
关于Lombok的@Data注解
Is it safe to open an account? How can anyone say that it is not reliable.
El input limit can only input numbers
[kotlin collaboration process] complete the advanced kotlin collaboration process
Talk about how the kotlin process started?
Interference source current spectrum test of current probe
Opencv learning notes -day10 logical operation of image pixels (usage of rectangle function and rect function and bit related operation in openCV)
Opencv learning notes -day4 image pixel reading and writing operations (array traversal and pointer traversal implementation, uchar vec3b data type and mat class functions mat:: at(), mat:: ptr())
Flink Exception -- No ExecutorFactory found to execute the application
mysql基础入门 day4 动力节点[老杜]课堂笔记
Do you want the dialog box that pops up from the click?
Interviewer: do you understand the principle of recyclerview layout animation?
Interpretation of orientedrcnn papers