Android NPU Demo exception when running on VIM4

Which version of system do you use? Khadas official images, self built images, or others?

Android 11 Khadas official https://dl.khadas.com/products/vim4/firmware/android/vim4-android-11-64bit-v230428.img.xz

Please describe your issue below:

Is the Android NPU Demos supposed to work on VIM4 (with NPU)? I am running this commit update detect_yolo_tiny demo to npu 6.4.8.7 · khadas/khadas_android_npu_app@ccd2da1 · GitHub

When I run the YoloFace Model demo (with a 1080p Camera, Logitech C615), it gives me the following exception:

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
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’
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 15394 (ImageListener), pid 15291 (.khadas.npudemo)

On the last line of VIM4 NPU Applications [Khadas Docs] it says that “Android” version is “Work In Progress”? Kindly confirm.

Please help.

Thanks.

Post a console log of your issue below:


Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/Zygote: seccomp disabled by setenforce 0
I/.khadas.npudem: Late-enabling -Xcheck:jni
I/.khadas.npudem: Unquickening 12 vdex files!
W/ActivityThread: Application com.khadas.npudemo is waiting for the debugger on port 8100...
I/System.out: Sending WAIT chunk
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
Connected to the target VM, address: 'localhost:61780', transport: 'socket'
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1332)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
E/MainActivity: button_yoloface
E/MainActivity: AlertDialog ok
E/MainActivity: button_yoloface enter 
W/libEGL: EGLNativeWindowType 0xb400006f7ed7d210 disconnect failed
D/OpenGLRenderer: endAllActiveAnimators on 0xb400006efed16d10 (RippleDrawable) with handle 0xb400006e1efa5d80
D/CameraActivity: CameraActivity enter 
I/.khadas.npudemo: type=1400 audit(0.0:453): avc: denied { search } for name="tmp" dev="dm-6" ino=506418 scontext=u:r:system_app:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=1
E/khadas_npu_det: FindClass com/example/khadasnpu/DetectResult sucess
E/khadas_npu_det: gDetectResultInitID 10839
D/CameraActivity: ------onCreate11   mode_type DET_YOLOFACE_V2
I/CameraManagerGlobal: Connecting to camera service
E/CameraActivity: facing = 1
I/CameraActivity: use Camera2 API?:true
D/CameraActivity: cameraId:0
D/CameraActivity: use Camera2 API
D/CameraActivity: copyNbFile enter
D/CameraActivity: copyNbFile deleteOnExit 
W/System.err: java.io.FileNotFoundException: yolo_face_99.nb
W/System.err:     at android.content.res.AssetManager.nativeOpenAsset(Native Method)
W/System.err:     at android.content.res.AssetManager.open(AssetManager.java:874)
W/System.err:     at android.content.res.AssetManager.open(AssetManager.java:851)
W/System.err:     at com.khadas.npudemo.CameraActivity.copyNbFile(CameraActivity.java:176)
W/System.err:     at com.khadas.npudemo.CameraActivity.onCreate(CameraActivity.java:300)
W/System.err:     at com.khadas.npudemo.ClassifierActivity.onCreate(ClassifierActivity.java:21)
W/System.err:     at android.app.Activity.performCreate(Activity.java:7994)
W/System.err:     at android.app.Activity.performCreate(Activity.java:7978)
W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3404)
W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
W/System.err:     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
W/System.err:     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
W/System.err:     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
W/System.err:     at android.os.Looper.loop(Looper.java:223)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7664)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)
D/KhadasNpuManager: ------npu_det_set_model begin 
D/khadas_npu_det: npu_det_set_models enter 
D/detect: jason jason det_set_model ############ modelType : 0 
D/detect: Read Cpuinfo:
    processor	: 0
    BogoMIPS	: 48.00
    Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
    CPU implementer	: 0x41
    CPU architecture: 8
    CPU variant	: 0x0
    CPU part	: 0xd09
    CPU revision	: 2
    
    processor	: 1
    BogoMIPS	: 48.00
    Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
    CPU implementer	: 0x41
    CPU architecture: 8
    CPU variant	: 0x0
    CPU part	: 0xd09
    CPU revision	: 2
    
    processor	: 2
    BogoMIPS	: 48.00
    Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
    CPU implementer	: 0x41
    CPU architecture: 8
    CPU variant	: 0x0
    CPU part	: 0xd09
    CPU revision	: 2
    
    processor	: 3
    BogoMIPS	: 48.00
    Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
    CPU implementer	: 0x41
    CPU architecture: 8
    CPU variant	: 0x0
    CPU part	: 0xd09
    CPU revision	: 2
    
    processor	: 4
    BogoMIPS	: 48.00
    Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
    CPU implementer	: 0x41
    CPU architecture: 8
    CPU variant	: 0x0
    CPU part	: 0xd03
    CPU revision	: 4
    
    processor	: 5
    BogoMIPS	: 48.00
    Features	: fp asimd evtstrm aes pmull sha1 
D/detect: 290 index=0
D/detect: set_dev_type DEV_MS1 and setenv 2 index=0 char:c
D/detect: Enter, dlopen so:libnn_yoloface.so
D/detect: dlopen libnn_yoloface.so failed!
D/detect: Leave, dlopen so:libnn_yoloface.so, ret=-1
D/detect: ModelType so open failed or Not support now!!
D/detect: Leave, modeltype:0
D/khadas_npu_det: npu_det_set_model fail 
D/khadas_npu_det: det_get_model_size fail 
D/CameraActivity: ------npu_det_set_model   setmoderesult -1
D/CameraActivity: onStart com.khadas.npudemo.ClassifierActivity@60f4b59
D/CameraActivity: onResume com.khadas.npudemo.ClassifierActivity@60f4b59
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073745664heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 3840height1944ratioWidth:0ratioHeight :0
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073745664heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 3840height1944ratioWidth:0ratioHeight :0
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073745664heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 3840height1944ratioWidth:0ratioHeight :0
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073745664heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 3840height1944ratioWidth:0ratioHeight :0
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073745664heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 3840height1944ratioWidth:0ratioHeight :0
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073745664heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 3840height1944ratioWidth:0ratioHeight :0
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073745664heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 3840height1944ratioWidth:0ratioHeight :0
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073745664heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 3840height1944ratioWidth:0ratioHeight :0
I/CameraConnectionFragment: camera2  LENS_FACING:1
I/CameraConnectionFragment:  Width: 1920Height1080
I/CameraConnectionFragment:  Width: 1600Height896
I/CameraConnectionFragment:  Width: 1280Height720
I/CameraConnectionFragment:  Width: 960Height720
I/CameraConnectionFragment:  Width: 1024Height576
I/CameraConnectionFragment:  Width: 800Height600
I/CameraConnectionFragment:  Width: 864Height480
I/CameraConnectionFragment:  Width: 800Height448
I/CameraConnectionFragment:  Width: 640Height480
I/CameraConnectionFragment:  Width: 640Height360
I/CameraConnectionFragment:  Width: 432Height240
I/CameraConnectionFragment:  Width: 352Height288
I/CameraConnectionFragment:  Width: 320Height240
I/CameraConnectionFragment:  Width: 176Height144
I/CameraConnectionFragment:  Width: 160Height120
I/CameraConnectionFragment: Exact size match found.
E/CameraActivity:  previewHeight = 1080previewWidth =1920
I/ClassifierActivity: Camera orientation relative to screen canvas: 0
I/ClassifierActivity: Initializing at size 1920x1080
I/CameraConnectionFragment: Opening camera preview: 1920x1080
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073745664heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 3840height1944ratioWidth:1920ratioHeight :1080
D/onMeasure: ------setMeasuredDimension   width: 3840width * ratioHeight / ratioWidth:2160
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073743744heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 1920height1944ratioWidth:1920ratioHeight :1080
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073745664heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 3840height1944ratioWidth:1920ratioHeight :1080
D/onMeasure: ------setMeasuredDimension   width: 3840width * ratioHeight / ratioWidth:2160
D/onMeasure: ------onMeasure   widthMeasureSpec: 1073743744heightMeasureSpec-2147481704
D/onMeasure: ------onMeasure   width: 1920height1944ratioWidth:1920ratioHeight :1080
D/CameraActivity: Enter onImageAvailable
W/libEGL: EGLNativeWindowType 0xb400006f7ed14d00 disconnect failed
D/CameraActivity: Enter onImageAvailable 22
D/CameraActivity: inputMat.height:1080,inputMat.width:1920
D/CameraActivity: imageByte len :2073600
D/CameraActivity: processImage enter
D/KhadasNpuManager: ------native_npu_det_set_input begin 
D/khadas_npu_det: npu_det_set_input v2 enter 11 
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
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'
A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 15394 (ImageListener), pid 15291 (.khadas.npudemo)
Disconnected from the target VM, address: 'localhost:61780', transport: 'socket'


@cedrictio This applies to VIM3/VIM3L. The Android NPU demo for VIM4 has not been completed yet.

Hi,

Thanks a lot for the quick reply. Appreciate it. Is there a rough estimate on when the Vim4 version will be ready?

Thanks.

GitHub link:

Download apks:
https://dl.khadas.com/development/khadas-vim4n-npu-release-v1.0.apk