Hi,
Recently github enabled opencv's extra classes through Python-for-android (including the face class). It has no trouble detecting the face binding boxes. It loads the LBF model, but then crashes when calling the 'cv2.face.fit' function on an android device. I am using opencv/opencv_contrib 4.0.1 and NDK 19. The relevant code is below:
img_1 = cv2.imread(ii_file)
img = cv2.cvtColor(img_1, cv2.COLOR_BGR2GRAY)
det = cv2.CascadeClassifier(lm_model)
faces = det.detectMultiScale(img)
l_det = cv2.face.createFacemarkLBF()
l_det.loadModel(lm_model_2)
ff_locations_01 = l_det.fit(img, faces)
Immediately after it calls 'l_det.fit(img,faces)', the stacktrace from adb logcat returns: ' F libc : /buildbot/src/android/ndk-release-r19/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type std::length_error: vector" failed'. Here is the full crash report that follows:
--------- beginning of crash 06-05 18:23:34.580 8134 8162 F libc : /buildbot/src/android/ndk-release-r19/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type std::length_error: vector" failed 06-05 18:23:37.604 8134 8162 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 8162 (SDLThread) 06-05 18:23:37.749 9203 9203 I AEE_AED : 06-05 18:23:37.750 9203 9203 I AEE_AED : Build fingerprint: 'OUKITEL/U22/U22:7.0/NRD90M/1508468660:user/release-keys' 06-05 18:23:37.750 9203 9203 I AEE_AED : Revision: '0' 06-05 18:23:37.750 9203 9203 I AEE_AED : ABI: 'arm' 06-05 18:23:37.750 9203 9203 I AEE_AED : pid: 8134, tid: 8162, name: SDLThread >>> com.aniface.aface <<< 06-05 18:23:37.750 9203 9203 I AEE_AED : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- 06-05 18:23:37.762 9203 9203 I AEE_AED : Abort message: '/buildbot/src/android/ndk-release-r19/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type std::length_error: vector" failed' 06-05 18:23:37.762 9203 9203 I AEE_AED : r0 00000000 r1 00001fe2 r2 00000006 r3 00000008 06-05 18:23:37.763 9203 9203 I AEE_AED : r4 97425978 r5 00000006 r6 97425920 r7 0000010c 06-05 18:23:37.763 9203 9203 I AEE_AED : r8 960bfe49 r9 97422b28 sl fbd00bff fp 00000000 06-05 18:23:37.763 9203 9203 I AEE_AED : ip 00000000 sp 97422528 lr b158b7d7 pc b158e034 cpsr 200f0010 06-05 18:23:37.787 9203 9203 I AEE_AED : 06-05 18:23:37.787 9203 9203 I AEE_AED : backtrace: 06-05 18:23:37.787 9203 9203 I AEE_AED : #00 pc 0004b034 /system/lib/libc.so (tgkill+12) 06-05 18:23:37.787 9203 9203 I AEE_AED : #1 pc 000487d3 /system/lib/libc.so (pthread_kill+34) 06-05 18:23:37.787 9203 9203 I AEE_AED : #2 pc 0001d785 /system/lib/libc.so (raise+10) 06-05 18:23:37.787 9203 9203 I AEE_AED : #3 pc 000192c1 /system/lib/libc.so (__libc_android_abort+34) 06-05 18:23:37.787 9203 9203 I AEE_AED : #4 pc 00017034 /system/lib/libc.so (abort+4) 06-05 18:23:37.787 9203 9203 I AEE_AED : #5 pc 0001b77f /system/lib/libc.so (__libc_fatal+22) 06-05 18:23:37.787 9203 9203 I AEE_AED : #6 pc 000194bb /system/lib/libc.so (__assert2+18) 06-05 18:23:37.787 9203 9203 I AEE_AED : #7 pc 00156019 /data/app/com.aniface.aface-2/lib/arm/libopencv_core.so 06-05 18:23:37.787 9203 9203 I AEE_AED : #8 pc 00156121 /data/app/com.aniface.aface-2/lib/arm/libopencv_core.so 06-05 18:23:37.788 9203 9203 I AEE_AED : #9 pc 00154679 /data/app/com.aniface.aface-2/lib/arm/libopencv_core.so 06-05 18:23:37.788 9203 9203 I AEE_AED : #10 pc 0015400f /data/app/com.aniface.aface-2/lib/arm/libopencv_core.so 06-05 18:23:37.788 9203 9203 I AEE_AED : #11 pc 00153fd7 /data/app/com.aniface.aface-2/lib/arm/libopencv_core.so (__cxa_throw+74) 06-05 18:23:37.788 9203 9203 I AEE_AED : #12 pc 0000b04d /data/app/com.aniface.aface-2/lib/arm/libopencv_face.so 06-05 18:23:37.788 9203 9203 I AEE_AED : #13 pc 0001d277 /data/app/com.aniface.aface-2/lib/arm/libopencv_face.so 06-05 18:23:37.788 9203 9203 I AEE_AED : #14 pc 00021aeb /data/app/com.aniface.aface-2/lib/arm/libopencv_face.so 06-05 18:23:37.788 9203 9203 I AEE_AED : #15 pc 0016844f /data/data/com.aniface.aface/files/app/_python_bundle/site-packages/cv2.so 06-05 18:23:37.788 9203 9203 I AEE_AED : #16 pc 00060750 /data/app/com.aniface.aface-2/lib/arm/libpython3.8m.so 06-05 18:36:27.074 10251 10272 F libc : /buildbot/src/android/ndk-release-r19/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type std::length_error: vector" failed 06-05 18:36:29.060 10251 10272 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 10272 (SDLThread) 06-05 21:07:04.889 13676 13703 F libc : /buildbot/src/android/ndk-release-r19/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type std::length_error: vector" failed 06-05 21:07:04.890 13676 13703 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 13703 (SDLThread) 06-05 21:08:44.986 13820 13841 F libc : /buildbot/src/android/ndk-release-r19/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type std::length_error: vector" failed 06-05 21:08:44.987 13820 13841 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 13841 (SDLThread) 06-05 21:08:45.085 13858 13858 I AEE_AED : 06-05 21:08:45.085 13858 13858 I AEE_AED : Build fingerprint: 'OUKITEL/U22/U22:7.0/NRD90M/1508468660:user/release-keys' 06-05 21:08:45.085 13858 13858 I AEE_AED : Revision: '0' 06-05 21:08:45.086 13858 13858 I AEE_AED : ABI: 'arm' 06-05 21:08:45.086 13858 13858 I AEE_AED : pid: 13820, tid: 13841, name: SDLThread >>> com.aniface.aface <<< 06-05 21:08:45.086 13858 13858 I AEE_AED : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- 06-05 21:08:45.096 13858 13858 I AEE_AED : Abort message: '/buildbot/src/android/ndk-release-r19/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type std::length_error: vector" failed' 06-05 21:08:45.096 13858 13858 I AEE_AED : r0 00000000 r1 00003611 r2 00000006 r3 00000008 06-05 21:08:45.096 13858 13858 I AEE_AED : r4 97425978 r5 00000006 r6 97425920 r7 0000010c 06-05 21:08:45.096 13858 13858 I AEE_AED : r8 94cfee49 r9 97422b28 sl fbd00bff fp 00000000 06-05 21:08:45.096 13858 13858 I AEE_AED : ip 00000000 sp 97422528 lr b158b7d7 pc b158e034 cpsr 200f0010 06-05 21:08:45.115 13858 13858 I AEE_AED : 06-05 21:08:45.115 13858 13858 I AEE_AED : backtrace: 06-05 21:08:45.115 13858 13858 I AEE_AED : #00 pc 0004b034 /system/lib/libc.so (tgkill+12) 06-05 21:08:45.115 13858 13858 I AEE_AED : #1 pc 000487d3 /system/lib/libc.so (pthread_kill+34) 06-05 21:08:45.115 13858 13858 I AEE_AED : #2 pc 0001d785 /system/lib/libc.so (raise+10) 06-05 21:08:45.115 13858 13858 I AEE_AED : #3 pc 000192c1 /system/lib/libc.so (__libc_android_abort+34) 06-05 21:08:45.115 13858 13858 I AEE_AED : #4 pc 00017034 /system/lib/libc.so (abort+4) 06-05 21:08:45.115 13858 13858 I AEE_AED : #5 pc 0001b77f /system/lib/libc.so (__libc_fatal+22) 06-05 21:08:45.115 13858 13858 I AEE_AED : #6 pc 000194bb /system/lib/libc.so (__assert2+18) 06-05 21:08:45.115 13858 13858 I AEE_AED : #7 pc 00156019 /data/app/com.aniface.aface-2/lib/arm/libopencv_core.so 06-05 21:08:45.116 13858 13858 I AEE_AED : #8 pc 00156121 /data/app/com.aniface.aface-2/lib/arm/libopencv_core.so 06-05 21:08:45.116 13858 13858 I AEE_AED : #9 pc 00154679 /data/app/com.aniface.aface-2/lib/arm/libopencv_core.so 06-05 21:08:45.116 13858 13858 I AEE_AED : #10 pc 0015400f /data/app/com.aniface.aface-2/lib/arm/libopencv_core.so 06-05 21:08:45.116 13858 13858 I AEE_AED : #11 pc 00153fd7 /data/app/com.aniface.aface-2/lib/arm/libopencv_core.so (__cxa_throw+74) 06-05 21:08:45.116 13858 13858 I AEE_AED : #12 pc 0000b04d /data/app/com.aniface.aface-2/lib/arm/libopencv_face.so 06-05 21:08:45.116 13858 13858 I AEE_AED : #13 pc 0001d277 /data/app/com.aniface.aface-2/lib/arm/libopencv_face.so 06-05 21:08:45.116 13858 13858 I AEE_AED : #14 pc 00021aeb /data/app/com.aniface.aface-2/lib/arm/libopencv_face.so 06-05 21:08:45.116 13858 13858 I AEE_AED : #15 pc 0016844f /data/data/com.aniface.aface/files/app/_python_bundle/site-packages/cv2.so 06-05 21:08:45.116 13858 13858 I AEE_AED : #16 pc 00060750 /data/app/com.aniface.aface-2/lib/arm/libpython3.8m.so
I am finding it difficult to diagnose what the problem is. Is it a memory issue for example? Could it be the version of NDK I am using? Any help would be great appreciated,
thanks