Has anyone tried real-time face detection using Camera2 API in Android?

Hello.

I need help right now.

I am trying the face recognition function using camera2 api.

I’ve tested numerous examples on github, and I’m looking for a way to do face recognition using mlkit and mediapipe.

My development level is very low and other examples cannot be applied because there are many examples using camera1 api or cameraX api.

please help me…

From what I’ve found, Camera2 knows that it needs to convert the YUV format. But I also don’t know how.

I definitely want to make a face recognition function using camera2 api.

I need your help… :sob:

you can refer VIM3&VIM3L Android NPU APP Initial Version Release
you can find the code about using camera2 api

OMG LOL Thank YOU! i try this!!

Hello, I listened to your advice and installed and tested the Android NPU APP.
I checked until the cam turned on, and then it shuts down.

Below is the error log I checked. Can you please confirm?

2021-09-09 11:27:29.474 27567-27567/com.khadas.npudemo E/CameraConnectionFragment: Couldn’t find any suitable preview size
2021-09-09 11:27:29.476 27567-27567/com.khadas.npudemo E/CameraActivity: previewHeight = 720previewWidth =1280

2021-09-09 11:27:30.392 27567-27701/com.khadas.npudemo E/cv::error(): OpenCV(4.4.0) Error: Assertion failed (inv_scale_x > 0) in resize, file /build/master_pack-android/opencv/modules/imgproc/src/resize.cpp, line 3932
2021-09-09 11:27:30.393 27567-27701/com.khadas.npudemo E/libc++abi: terminating with uncaught exception of type cv::Exception: OpenCV(4.4.0) /build/master_pack-android/opencv/modules/imgproc/src/resize.cpp:3932: error: (-215:Assertion failed) inv_scale_x > 0 in function ‘resize’
2021-09-09 11:27:30.393 27567-27701/com.khadas.npudemo A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 27701 (ImageListener), pid 27567 (.khadas.npudemo)

what is the firmware version you using?

i used
VIM3

version = 9
Kernel version = 4.9.113

build = VIM3_Pie_V201112

Well, maybe it’s because my version is low?

In fact, it was confirmed that rooting was required while using the unrooted version of the firmware before that, so I wrote it to the existing rooting image file and tested it.

Sorry if this was a simple version issue.

if you want to run npu ,you should burn VIM3_Pie_V20210527 firmware

Thank you.
It seems to be solved with your help.
I am so lucky to have you read this writing!

I wish you a happy day!! :blush:

Let me ask you one more thing.
When I checked the firmware, there was also a firmware that was recently updated.

Can all firmware of VIM3_Pie_V20210527 or higher use npu?

yes,VIM3_Pie_V20210527 or higher can use npu

thank you, thank you lol!!!
have a nice day! :heart_eyes_cat: