In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how Android based on ArcSoft to achieve face recognition, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Create your own application in Hongrou's developer center and record APP_ID and SDK_KEY, which will be used later. After you create it, you can download SDK.
2. After downloading, you can refer to and learn according to the development instructions and code in the SDK package. The following is a screenshot of the SDK package structure in the development documentation.
< facePreviewInfoList.size(); i++) { Integer status = requestFeatureStatusMap.get(facePreviewInfoList.get(i).getTrackId()); /** * 在活体检测开启,在人脸识别状态不为成功或人脸活体状态不为处理中(ANALYZING)且不为处理完成(ALIVE、NOT_ALIVE)时重新进行活体检测 */ if (livenessDetect && (status == null || status != RequestFeatureStatus.SUCCEED)) { Integer liveness = livenessMap.get(facePreviewInfoList.get(i).getTrackId()); if (liveness == null || (liveness != LivenessInfo.ALIVE && liveness != LivenessInfo.NOT_ALIVE && liveness != RequestLivenessStatus.ANALYZING)) { livenessMap.put(facePreviewInfoList.get(i).getTrackId(), RequestLivenessStatus.ANALYZING); faceHelper.requestFaceLiveness(nv21, facePreviewInfoList.get(i).getFaceInfo(), previewSize.width, previewSize.height, FaceEngine.CP_PAF_NV21, facePreviewInfoList.get(i).getTrackId(), LivenessType.RGB); } } /** * 对于每个人脸,若状态为空或者为失败,则请求特征提取(可根据需要添加其他判断以限制特征提取次数), * 特征提取回传的人脸特征结果在{@link FaceListener#onFaceFeatureInfoGet(FaceFeature, Integer, Integer)}中回传 */ if (status == null || status == RequestFeatureStatus.TO_RETRY) { requestFeatureStatusMap.put(facePreviewInfoList.get(i).getTrackId(), RequestFeatureStatus.SEARCHING); faceHelper.requestFaceFeature(nv21, facePreviewInfoList.get(i).getFaceInfo(), previewSize.width, previewSize.height, FaceEngine.CP_PAF_NV21, facePreviewInfoList.get(i).getTrackId());// Log.i(TAG, "onPreview: fr start = " + System.currentTimeMillis() + " trackId = " + facePreviewInfoList.get(i).getTrackedFaceCount()); } } } } @Override public void onCameraClosed() { Log.i(TAG, "onCameraClosed: "); } @Override public void onCameraError(Exception e) { Log.i(TAG, "onCameraError: " + e.getMessage()); } @Override public void onCameraConfigurationChanged(int cameraID, int displayOrientation) { if (drawHelper != null) { drawHelper.setCameraDisplayOrientation(displayOrientation); } Log.i(TAG, "onCameraConfigurationChanged: " + cameraID + " " + displayOrientation); } }; cameraHelper = new CameraHelper.Builder() .previewViewSize(new Point(previewView.getMeasuredWidth(), previewView.getMeasuredHeight())) .rotation(getWindowManager().getDefaultDisplay().getRotation()) .specificCameraId(rgbCameraID != null ? rgbCameraID : Camera.CameraInfo.CAMERA_FACING_FRONT) .isMirror(false) .previewOn(previewView) .cameraListener(cameraListener) .build(); cameraHelper.init(); cameraHelper.start(); } 注册人脸的逻辑: private void registerFace(final byte[] nv21, final List facePreviewInfoList) { if (registerStatus == REGISTER_STATUS_READY && facePreviewInfoList != null && facePreviewInfoList.size() >0) {registerStatus = REGISTER_STATUS_PROCESSING Observable.create (new ObservableOnSubscribe () {@ Override public void subscribe (ObservableEmitter emitter) {boolean success = FaceServer.getInstance () .registerNv21 (FaceRegisterAndRecognise.this, nv21.clone (), previewSize.width, previewSize.height, facePreviewInfoList.get (0) .getFaceInfo (), "registered" + faceHelper.getTrackedFaceCount ()) Emitter.onNext (success) ) .subscribeOn (Schedulers.computation ()) .subscrieOn (AndroidSchedulers.mainThread ()) .subscribe (new Observer () {@ Override public void onSubscribe (Disposable d)) { } @ Override public void onNext (Boolean success) {String result = success? "register success!": "register failed!"; showToast (result); registerStatus = REGISTER_STATUS_DONE;} @ Override public void onError (Throwable e) {e.printStackTrace () ShowToast ("register failed!"); registerStatus = REGISTER_STATUS_DONE;} @ Override public void onComplete () {}};}}
13. The management interface of face database.
Public class FaceLibs extends BaseActivity {private ExecutorService executorService; private TextView textView; private TextView tvNotificationRegisterResult; ProgressDialog progressDialog = null; private static final int ACTION_REQUEST_PERMISSIONS = 0x001; private static String [] NEEDED_PERMISSIONS = new String [] {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}; @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState) SetContentView (R.layout.activity_face_libs); getWindow (). AddFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); executorService = Executors.newSingleThreadExecutor (); tvNotificationRegisterResult = findViewById (R.id.notification_register_result); progressDialog = new ProgressDialog (this); int faceLibNum = FaceServer.getInstance (). GetFaceNumber (this); textView = findViewById (R.id.number); textView.setText (faceLibNum + ") FaceServer.getInstance () .init (this);} @ Override protected void onDestroy () {if (executorService! = null & &! executorService.isShutdown ()) {executorService.shutdownNow ();} if (progressDialog! = null & & progressDialog.isShowing ()) {progressDialog.dismiss ();} FaceServer.getInstance () .unInit (); super.onDestroy () } @ Override void afterRequestPermission (int requestCode, boolean isAllGranted) {} public void clearFaces (View view) {int faceNum = FaceServer.getInstance () .getFaceNumber (this); if (faceNum = = 0) {showToast ("face database is empty!") ;} else {AlertDialog dialog = new AlertDialog.Builder (this) .setTitle ("Notification") .setMessage ("sure you want to delete" + faceNum + "personal face?") .setPositiveButton ("OK", new DialogInterface.OnClickListener () {@ Override public void onClick (DialogInterface dialog, int which) {int deleteCount = FaceServer.getInstance () .clearAllFaces (FaceLibs.this); showToast (deleteCount + "personal face deleted!") ; textView.setText ("0");}) .setNegativeButton ("cancel", null) .create (); dialog.show ();}
14. The above is a general introduction, and there are still some minor details to be practiced by comrades. Let's take a look at the effect of the implementation.
Main interface:
Successfully registered and identified:
Identify that it is not alive by cell phone photos:
Clean up the face database:
The above is all the contents of the article "how to realize face recognition based on ArcSoft in Android". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.