Giter Site home page Giter Site logo

deeparsdk / quickstart-android-java Goto Github PK

View Code? Open in Web Editor NEW
28.0 4.0 18.0 73.46 MB

DeepAR SDK for Android example project

Home Page: https://developer.deepar.ai

License: MIT License

Java 100.00%
android java augmented-reality face-filters deepar

quickstart-android-java's Introduction

quickstart-android-java

Overview

This is an example app demonstrating DeepAR SDK.

  • Preview of fun face filters, effects and background replacement.
  • Carousel with filter thumbnails.
  • Take screenshot.
  • Record video.
  • Front and back camera.
  • Source code demonstrates how to integrate DeepAR for Android in your app.

For more info on DeepAR for Android see: https://docs.deepar.ai/deepar-sdk/platforms/android/overview

How to run

  1. Open the project in Android Studio.
  2. Create a DeepAR developer account: https://developer.deepar.ai/signup.
  3. Create a project: https://developer.deepar.ai/projects.
  4. Add a Android app to the project. Note that you need to specify the applicationId of your app. The applicationId is located in the app/build.gradle and in this case it is "ai.deepar.deepar_example".
  5. Copy the generated license key in the MainActivity.java instead of your_license_key_here.

quickstart-android-java's People

Contributors

cstdbool avatar dishod avatar djanekovicdeepar avatar forec1 avatar igor-aradski avatar jelenakb avatar luka-m avatar mategasparini avatar sikter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

quickstart-android-java's Issues

Camera Resolution Issue

While I am Using default Camera resolution enum class but SDK throws ERROR Invalid output width and/or height

how to know changeParameterTexture finish?

I have one list filter to apply the camera, but the user click multi filter at one time and my app throws an error
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 2702 (Thread-2316), pid 32214

Issue with SIGNED APK Android

The App is getting crash in signed APK, working fine in debug mode.

logs

2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception java.lang.NoSuchMethodError: no non-static method "Lai/deepar/ar/DeepAR;.messageFromNative(Ljava/lang/String;Ljava/lang/String;)V"
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] (Throwable with empty stack trace)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542]
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] in call to CallVoidMethodV
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] "Thread-45" prio=10 tid=156 Runnable
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] | group="main" sCount=0 dsCount=0 flags=0 obj=0x13f00000 self=0x79dc1cac00
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] | sysTid=14841 nice=-10 cgrp=default sched=0/0 handle=0x79aab564f0
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] | state=R schedstat=( 40404584 16814166 59 ) utm=3 stm=1 core=6 HZ=100
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] | stack=0x79aaa5b000-0x79aaa5d000 stackSize=1009KB
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] | held mutexes= "mutator lock"(shared held)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #00 pc 00000000003c2958 /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+220)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #1 pc 0000000000490080 /system/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, BacktraceMap*, bool) const+352)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #2 pc 00000000002e5e18 /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+968)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #3 pc 00000000002e6228 /system/lib64/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, std::__va_list)+116)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #4 pc 00000000000fd1fc /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...)+148)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #5 pc 00000000000fbbd8 /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+1152)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #6 pc 00000000000faf44 /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+628)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #7 pc 00000000001009e0 /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CheckCallArgs(art::ScopedObjectAccess&, art::(anonymous namespace)::ScopedCheck&, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, art::InvokeType, art::(anonymous namespace)::VarArgs const*)+132)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #8 pc 00000000000ff814 /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType)+724)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #9 pc 00000000000ed364 /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+92)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #10 pc 000000000007d848 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #11 pc 000000000007d794 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #12 pc 00000000000d6b50 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #13 pc 00000000000d69b0 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #14 pc 00000000000d7abc /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #15 pc 00000000000cc58c /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #16 pc 000000000009273c /system/lib64/libc.so (__pthread_start(void*)+36)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] native: #17 pc 0000000000023c78 /system/lib64/libc.so (__start_thread+68)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542] (no managed stack frames)
2020-07-11 12:36:06.522 14083-14841/? A/pp.clapio.musi: java_vm_ext.cc:542]
2020-07-11 12:36:06.571 14083-14841/? A/pp.clapio.musi: thread.cc:2148] No pending exception expected: java.lang.NoSuchMethodError: no non-static method "Lai/deepar/ar/DeepAR;.messageFromNative(Ljava/lang/String;Ljava/lang/String;)V"
2020-07-11 12:36:06.571 14083-14841/? A/pp.clapio.musi: thread.cc:2148] (Throwable with empty stack trace)
2020-07-11 12:36:06.571 14083-14841/? A/pp.clapio.musi: thread.cc:2148]
2020-07-11 12:36:06.588 14083-14841/? A/pp.clapio.musi: runtime.cc:561] Runtime aborting --- recursively, so no thread-specific detail!
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #00 pc 00000000003c2958 /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+220)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #1 pc 00000000004651dc /system/lib64/libart.so (art::Runtime::Abort(char const*)+308)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #2 pc 0000000000008ce0 /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+724)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #3 pc 00000000004951c4 /system/lib64/libart.so (art::Thread::AssertNoPendingException() const+1152)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #4 pc 000000000011bffc /system/lib64/libart.so (art::ClassLinker::FindClass(art::Thread*, char const*, art::Handleart::mirror::ClassLoader)+64)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #5 pc 00000000001365f4 /system/lib64/libart.so (art::ClassLinker::DoResolveType(art::dex::TypeIndex, art::Handleart::mirror::DexCache, art::Handleart::mirror::ClassLoader)+188)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #6 pc 00000000004bf77c /system/lib64/libart.so (art::verifier::MethodVerifier::ScanTryCatchBlocks()+504)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #7 pc 00000000004bc990 /system/lib64/libart.so (art::verifier::MethodVerifier::Verify()+684)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #8 pc 00000000004bf24c /system/lib64/libart.so (art::verifier::MethodVerifier::FindLocksAtDexPc()+140)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #9 pc 00000000004bf134 /system/lib64/libart.so (art::verifier::MethodVerifier::FindLocksAtDexPc(art::ArtMethod*, unsigned int, std::__1::vector<art::verifier::MethodVerifier::DexLockInfo, std::__1::allocatorart::verifier::MethodVerifier::DexLockInfo>)+524)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #10 pc 00000000003c023c /system/lib64/libart.so (art::Monitor::VisitLocks(art::StackVisitor
, void ()(art::mirror::Object, void*), void*, bool)+812)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #11 pc 000000000049e704 /system/lib64/libart.so (art::MonitorObjectsStackVisitor::VisitFrame()+164)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #12 pc 000000000047ea54 /system/lib64/libart.so (_ZN3art12StackVisitor9WalkStackILNS0_16CountTransitionsE0EEEvb+1644)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #13 pc 0000000000493fbc /system/lib64/libart.so (art::Thread::DumpJavaStack(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, bool) const+320)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #14 pc 0000000000490098 /system/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, BacktraceMap*, bool) const+376)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #15 pc 00000000004a9cd4 /system/lib64/libart.so (art::DumpCheckpoint::Run(art::Thread*)+844)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #16 pc 00000000004a2e94 /system/lib64/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+1464)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #17 pc 00000000004a1edc /system/lib64/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits>&, bool)+1088)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #18 pc 000000000046522c /system/lib64/libart.so (art::Runtime::Abort(char const*)+388)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #19 pc 0000000000008ce0 /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+724)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #20 pc 00000000002e60b8 /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1640)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #21 pc 00000000002e6228 /system/lib64/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, std::__va_list)+116)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #22 pc 00000000000fd1fc /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...)+148)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #23 pc 00000000000fbbd8 /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+1152)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #24 pc 00000000000faf44 /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+628)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #25 pc 00000000001009e0 /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CheckCallArgs(art::ScopedObjectAccess&, art::(anonymous namespace)::ScopedCheck&, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, art::InvokeType, art::(anonymous namespace)::VarArgs const*)+132)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #26 pc 00000000000ff814 /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType)+724)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #27 pc 00000000000ed364 /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+92)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #28 pc 000000000007d848 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #29 pc 000000000007d794 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #30 pc 00000000000d6b50 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #31 pc 00000000000d69b0 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #32 pc 00000000000d7abc /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #33 pc 00000000000cc58c /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so (???)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #34 pc 000000000009273c /system/lib64/libc.so (__pthread_start(void*)+36)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561] #35 pc 0000000000023c78 /system/lib64/libc.so (__start_thread+68)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:561]
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:569] No pending exception expected: java.lang.NoSuchMethodError: no non-static method "Lai/deepar/ar/DeepAR;.messageFromNative(Ljava/lang/String;Ljava/lang/String;)V"
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:569] (Throwable with empty stack trace)
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:569]
2020-07-11 12:36:06.589 14083-14841/? A/pp.clapio.musi: runtime.cc:569]
2020-07-11 12:36:06.589 14083-14841/? A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 14841 (Thread-45), pid 14083 (pp.clapio.music)

2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: Softversion: PD1921BF_EX_A_1.11.4
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: Time: 2020-07-11 12:36:06
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: Build fingerprint: 'vivo/1917/1917:9/PKQ1.181030.001/compiler05071131:user/release-keys'
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: Revision: '0'
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: ABI: 'arm64'
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: pid: 14083, tid: 14841, name: Thread-45 >>> app.clapio.music <<<
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: Abort message: 'java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception java.lang.NoSuchMethodError: no non-static method "Lai/deepar/ar/DeepAR;.messageFromNative(Ljava/lang/String;Ljava/lang/String;)V"'
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: x0 0000000000000000 x1 00000000000039f9 x2 0000000000000006 x3 0000000000000008
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: x4 0000000000000000 x5 0000000000000000 x6 0000000000000000 x7 0000000000000080
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: x8 0000000000000083 x9 f928e5b49eef7f6e x10 0000000000000000 x11 fffffffc7ffffbdf
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: x12 0000000000000001 x13 0000000000000038 x14 ffffffffffffffff x15 0000603da794b7a7
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: x16 0000007a8811d298 x17 0000007a8803ed14 x18 0000000000000010 x19 0000000000003703
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: x20 00000000000039f9 x21 00000079d79f82c0 x22 0000000000000000 x23 0000007a01b77c30
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: x24 0000000000000000 x25 00000079aab54589 x26 0000007a01b77c30 x27 0000000000001b46
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: x28 00000079aab56588 x29 00000079aab544f0
2020-07-11 12:36:06.756 14853-14853/? A/DEBUG: sp 00000079aab544b0 lr 0000007a88030394 pc 0000007a880303bc
2020-07-11 12:36:06.760 14853-14853/? A/DEBUG: backtrace:
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #00 pc 00000000000223bc /system/lib64/libc.so (abort+116)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #1 pc 0000000000465554 /system/lib64/libart.so (art::Runtime::Abort(char const*)+1196)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #2 pc 0000000000008ce0 /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+724)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #3 pc 00000000004951c4 /system/lib64/libart.so (art::Thread::AssertNoPendingException() const+1152)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #4 pc 000000000011bffc /system/lib64/libart.so (art::ClassLinker::FindClass(art::Thread*, char const*, art::Handleart::mirror::ClassLoader)+64)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #5 pc 00000000001365f4 /system/lib64/libart.so (art::ClassLinker::DoResolveType(art::dex::TypeIndex, art::Handleart::mirror::DexCache, art::Handleart::mirror::ClassLoader)+188)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #6 pc 00000000004bf77c /system/lib64/libart.so (art::verifier::MethodVerifier::ScanTryCatchBlocks()+504)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #7 pc 00000000004bc990 /system/lib64/libart.so (art::verifier::MethodVerifier::Verify()+684)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #8 pc 00000000004bf24c /system/lib64/libart.so (art::verifier::MethodVerifier::FindLocksAtDexPc()+140)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #9 pc 00000000004bf134 /system/lib64/libart.so (art::verifier::MethodVerifier::FindLocksAtDexPc(art::ArtMethod*, unsigned int, std::__1::vector<art::verifier::MethodVerifier::DexLockInfo, std::__1::allocatorart::verifier::MethodVerifier::DexLockInfo>)+524)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #10 pc 00000000003c023c /system/lib64/libart.so (art::Monitor::VisitLocks(art::StackVisitor
, void ()(art::mirror::Object, void*), void*, bool)+812)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #11 pc 000000000049e704 /system/lib64/libart.so (art::MonitorObjectsStackVisitor::VisitFrame()+164)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #12 pc 000000000047ea54 /system/lib64/libart.so (_ZN3art12StackVisitor9WalkStackILNS0_16CountTransitionsE0EEEvb+1644)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #13 pc 0000000000493fbc /system/lib64/libart.so (art::Thread::DumpJavaStack(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, bool) const+320)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #14 pc 0000000000490098 /system/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, BacktraceMap*, bool) const+376)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #15 pc 00000000004a9cd4 /system/lib64/libart.so (art::DumpCheckpoint::Run(art::Thread*)+844)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #16 pc 00000000004a2e94 /system/lib64/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+1464)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #17 pc 00000000004a1edc /system/lib64/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits>&, bool)+1088)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #18 pc 000000000046522c /system/lib64/libart.so (art::Runtime::Abort(char const*)+388)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #19 pc 0000000000008ce0 /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+724)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #20 pc 00000000002e60b8 /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1640)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #21 pc 00000000002e6228 /system/lib64/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, std::__va_list)+116)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #22 pc 00000000000fd1fc /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...)+148)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #23 pc 00000000000fbbd8 /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+1152)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #24 pc 00000000000faf44 /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+628)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #25 pc 00000000001009e0 /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CheckCallArgs(art::ScopedObjectAccess&, art::(anonymous namespace)::ScopedCheck&, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, art::InvokeType, art::(anonymous namespace)::VarArgs const*)+132)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #26 pc 00000000000ff814 /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType)+724)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #27 pc 00000000000ed364 /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+92)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #28 pc 000000000007d848 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #29 pc 000000000007d794 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #30 pc 00000000000d6b50 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #31 pc 00000000000d69b0 /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #32 pc 00000000000d7abc /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #33 pc 00000000000cc58c /data/app/app.clapio.music-r-AOev3FmV-xuoFvCJW0Xg==/lib/arm64/libnative-lib.so
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #34 pc 000000000009273c /system/lib64/libc.so (__pthread_start(void*)+36)
2020-07-11 12:36:06.761 14853-14853/? A/DEBUG: #35 pc 0000000000023c78 /system/lib64/libc.so (__start_thread+68)

Need Switch Preview option

Is there any way to switch the camera preview and remote video preview. if i am switching it the latest one is showing on the top.

Older preview is hiding behind the latest preview.

"Failed to update user data." on sign up

I'm tring to sign up for the sdk, but it is saying "Failed to update user data." plus it is asking for vat id, I'm a indivitual developer + student, I don't have it.

plz help me to sign up

Null Pointer Dereference in switchEffectRawNative

Hello everyone,

Summary

I am using DeepAR in conjunction with Flutter. I am creating a Flutter plugin for Android. I use the JetPack support library CameraX for camera access. The library provides a use case called "ImageAnalyse" (https://developer.android.com/training/camerax/analyze). I try to combine this with DeepAR. The masks that I want to display with DeepAR via the camera are in the App Bundle as assets. When I call "switchEffect", the app crashes.

Code Excerpt

The Flutter Plugin

The architecture of the Flutter Plugin follows the recommendations in the Flutter documentation

class ExamplePlugin : FlutterPlugin, ActivityAware {
    private var flutterPluginBinding: FlutterPluginBinding? = null
    private var activityPluginBinding: ActivityPluginBinding? = null
    // overrides are implemented but left out for simplicity
}
class PluginViewFactory(
    private val flutterPluginBinding: FlutterPlugin.FlutterPluginBinding, private val activityPluginBinding: ActivityPluginBinding
) : PlatformViewFactory(StandardMessageCodec.INSTANCE) {

    override fun create(context: Context?, id: Int, args: Any?): PlatformView {
        return PluginView(flutterPluginBinding, activityPluginBinding, context, id, args)
    }
}
class PluginView(
    flutterPluginBinding: FlutterPluginBinding,
    activityPluginBinding: ActivityPluginBinding,
    private val context: Context?,
    id: Int,
    args: Any?
) : PlatformView, MethodChannel.MethodCallHandler, PluginRegistry.RequestPermissionsResultListener,
    AREventListener {
    private val activity = activityPluginBinding.activity
    // I left out some code for simplicity

Create a ProcessCameraProvider

    private fun startCamera() {
        val cameraProviderFuture = ProcessCameraProvider.getInstance(activity)
        cameraProviderFuture.addListener({
            cameraProvider = cameraProviderFuture.get()
            bindPreviewAndAnalysis(cameraProvider)
        }, ContextCompat.getMainExecutor(activity))
    }

Bind image preview and image analysis use case

    private fun bindPreviewAndAnalysis(cameraProvider: ProcessCameraProvider?) {
        // Preview
        val imagePreview = Preview.Builder()
            .build()
            .also {
                it.setSurfaceProvider(previewView.surfaceProvider)
            }

        // Analysis
        val cameraPreset = CameraResolutionPreset.P1280x720
        val width: Int
        val height: Int
        val orientation: Int = getScreenOrientation()
        if (orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE || orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            width = cameraPreset.width
            height = cameraPreset.height
        } else {
            width = cameraPreset.height
            height = cameraPreset.width
        }
        arrayOfNulls<ByteBuffer>(NUMBER_OF_BUFFERS).also { buffers = it }
        for (i in 0 until NUMBER_OF_BUFFERS) {
            buffers[i] = ByteBuffer.allocateDirect(width * height * 3)
            buffers[i]?.order(ByteOrder.nativeOrder())
            buffers[i]?.position(0)
        }
        val imageAnalysis = ImageAnalysis.Builder().setTargetResolution(Size(width, height))
            .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST).build()
        cameraExecutor?.let {
            imageAnalysis.setAnalyzer(
                it,
                { image ->
                    val byteData: ByteArray
                    val yBuffer: ByteBuffer = image.planes[0].buffer
                    val uBuffer: ByteBuffer = image.planes[1].buffer
                    val vBuffer: ByteBuffer = image.planes[2].buffer
                    val ySize: Int = yBuffer.remaining()
                    val uSize: Int = uBuffer.remaining()
                    val vSize: Int = vBuffer.remaining()
                    byteData = ByteArray(ySize + uSize + vSize)

                    //U and V are swapped
                    yBuffer.get(byteData, 0, ySize)
                    vBuffer.get(byteData, ySize, vSize)
                    uBuffer.get(byteData, ySize + vSize, uSize)
                    buffers[currentBuffer]?.put(byteData)
                    buffers[currentBuffer]?.position(0)
                    if (deepAR != null) {
                        deepAR?.receiveFrame(
                            buffers[currentBuffer],
                            image.width,
                            image.height,
                            image.imageInfo.rotationDegrees,
                            cameraSelector == CameraSelector.DEFAULT_FRONT_CAMERA,
                            DeepARImageFormat.YUV_420_888,
                            image.planes[1].pixelStride
                        )
                    }
                    currentBuffer = (currentBuffer + 1) % NUMBER_OF_BUFFERS
                    image.close()
                })
        }

        try {
            cameraProvider?.unbindAll()

            cameraSelector?.let {
                cameraProvider?.bindToLifecycle(activity as LifecycleOwner,
                    it, imagePreview, imageAnalysis)
            }
        } catch (e: Exception) {
            Log.e(TAG, "Use case binding failed", e)
        }
    }

use DeepAR switchEffect

    private fun changeMask(mask: String) {
        try {
            val loader = FlutterInjector.instance().flutterLoader()
            val path = loader.getLookupKeyForAsset("assets/masks/$mask", "my_plugin_name")
            val maskFd: AssetFileDescriptor = activity.assets.openFd(path)
            deepAR?.switchEffect("masks", maskFd.createInputStream())
        } catch (exc: Exception) {
            Log.e(TAG, "Could not change mask", exc)
        }
    }

Error

When the "switchEffect" is called, the app crashes with the following error:

F/libc    (20852): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 20852 (.example.app), pid 20852 (.example.app)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/walleye/walleye:11/RP1A.201005.004.A1/6934943:user/release-keys'
Revision: 'MP1'
ABI: 'arm64'
Timestamp: 2021-07-25 13:59:29+0200
pid: 20852, tid: 20852, name: .example.app  >>> com.example.app <<<
uid: 10194
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    x0  0000007129de3570  x1  0000007129de3570  x2  0000007139e3b210  x3  0000007119769984
    x4  0000007ff61c6788  x5  0000000000000000  x6  0000000000000001  x7  6ced3fea237c8a73
    x8  0000000000000000  x9  6ced3fea237c8a73  x10 0000000000430000  x11 0000000029de3576
    x12 000000005375645e  x13 0000007ff61c68a0  x14 0000000000000002  x15 00000000ebad6a89
    x16 00000073acaaa7f8  x17 00000073aabc5bd0  x18 00000073af972000  x19 0000007139e3b210
    x20 0000007ff61c68b0  x21 00000071d9d95c70  x22 0000000000000001  x23 0000007ff61c68b4
    x24 0000000000000000  x25 00000073af273000  x26 0000000000000069  x27 0000007119d77000
    x28 0000007ff61c68c0  x29 0000007ff61c6890
    lr  000000707f88e504  sp  0000007ff61c6850  pc  000000707f88e514  pst 0000000060000000
backtrace:
      #00 pc 000000000004a514  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libnative-lib.so (Java_ai_deepar_ar_DeepAR_switchEffectRawNative+268) (BuildId: 342abf6bf48a1e62b230a5496cbaeecab0b6c701)
      #01 pc 000000000013ced4  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: d0f321775158ed00df284edfabf672b6)
      #02 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d0f321775158ed00df284edfabf672b6)
      #03 pc 00000000001a97e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #04 pc 000000000031c040  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: d0f321775158ed00df284edfabf672b6)
      #05 pc 0000000000313288  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+696) (BuildId: d0f321775158ed00df284edfabf672b6)
      #06 pc 000000000068b144  /apex/com.android.art/lib64/libart.so (MterpInvokeDirectRange+436) (BuildId: d0f321775158ed00df284edfabf672b6)
      #07 pc 000000000012dc14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_direct_range+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #08 pc 0000000000162a36  [anon:dalvik-classes.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk] (ai.deepar.ar.DeepAR.switchEffect+70)
      #09 pc 0000000000685960  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+1520) (BuildId: d0f321775158ed00df284edfabf672b6)
      #10 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #11 pc 000000000001a49c  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes2.dex] (com.example.plugin.PluginView.changeMask+296)
      #12 pc 0000000000687fe8  /apex/com.android.art/lib64/libart.so (MterpInvokeDirect+1248) (BuildId: d0f321775158ed00df284edfabf672b6)
      #13 pc 000000000012d914  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_direct+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #14 pc 000000000001a53a  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes2.dex] (com.example.plugin.PluginView.changeMaskNative+42)
      #15 pc 0000000000687fe8  /apex/com.android.art/lib64/libart.so (MterpInvokeDirect+1248) (BuildId: d0f321775158ed00df284edfabf672b6)
      #16 pc 000000000012d914  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_direct+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #17 pc 000000000001a962  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes2.dex] (com.example.plugin.PluginView.onMethodCall+154)
      #18 pc 00000000006873a4  /apex/com.android.art/lib64/libart.so (MterpInvokeInterface+1812) (BuildId: d0f321775158ed00df284edfabf672b6)
      #19 pc 000000000012da14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #20 pc 000000000036ef32  [anon:dalvik-classes6.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes6.dex] (io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage+34)
      #21 pc 00000000006873a4  /apex/com.android.art/lib64/libart.so (MterpInvokeInterface+1812) (BuildId: d0f321775158ed00df284edfabf672b6)
      #22 pc 000000000012da14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #23 pc 0000000000364daa  [anon:dalvik-classes6.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes6.dex] (io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart+114)
      #24 pc 00000000006873a4  /apex/com.android.art/lib64/libart.so (MterpInvokeInterface+1812) (BuildId: d0f321775158ed00df284edfabf672b6)
      #25 pc 000000000012da14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #26 pc 0000000000363a64  [anon:dalvik-classes6.dex extracted in memory from /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/base.apk!classes6.dex] (io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage+8)
      #27 pc 00000000003094d0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.7618685802058321727)+264) (BuildId: d0f321775158ed00df284edfabf672b6)
      #28 pc 00000000006740c0  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+776) (BuildId: d0f321775158ed00df284edfabf672b6)
      #29 pc 000000000013cff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: d0f321775158ed00df284edfabf672b6)
      #30 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d0f321775158ed00df284edfabf672b6)
      #31 pc 00000000001a97e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #32 pc 000000000055c6f4  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+468) (BuildId: d0f321775158ed00df284edfabf672b6)
      #33 pc 000000000055c894  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+92) (BuildId: d0f321775158ed00df284edfabf672b6)
      #34 pc 00000000004197f8  /apex/com.android.art/lib64/libart.so (art::JNI<true>::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+656) (BuildId: d0f321775158ed00df284edfabf672b6)
      #35 pc 000000000037deac  /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType)+2532) (BuildId: d0f321775158ed00df284edfabf672b6)
      #36 pc 000000000036bc50  /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+72) (BuildId: d0f321775158ed00df284edfabf672b6)
      #37 pc 000000000132663c  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #38 pc 0000000001326578  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #39 pc 0000000001322408  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #40 pc 000000000138428c  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #41 pc 0000000001342568  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #42 pc 00000000013476f8  /data/app/~~tCz51U3rHjeb2hAFXQB6yw==/com.example.app-xzIovrW9JsSRapHSrOSbnA==/lib/arm64/libflutter.so (BuildId: 137d09ab83a412ded1c33ef386351fcc0429a53b)
      #43 pc 000000000001a064  /system/lib64/libutils.so (android::Looper::pollInner(int)+916) (BuildId: b81fad2b6b7b7f85c6217d2cb80c9e61)
      #44 pc 0000000000019c68  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+112) (BuildId: b81fad2b6b7b7f85c6217d2cb80c9e61)
      #45 pc 00000000001120f4  /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+44) (BuildId: 30f3430e4d2a28be49d3c60d623f0a29)
      #46 pc 000000000020fadc  /system/framework/arm64/boot-framework.oat (art_jni_trampoline+140) (BuildId: da25c976c2d1d3af123868772655a0779f8f6a48)
      #47 pc 000000000200b6cc  /memfd:jit-cache (deleted) (offset 0x2000000) (android.os.MessageQueue.next+204)
      #48 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d0f321775158ed00df284edfabf672b6)
      #49 pc 00000000001a97e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #50 pc 000000000031c040  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: d0f321775158ed00df284edfabf672b6)
      #51 pc 0000000000312228  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+912) (BuildId: d0f321775158ed00df284edfabf672b6)
      #52 pc 00000000006856c0  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+848) (BuildId: d0f321775158ed00df284edfabf672b6)
      #53 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #54 pc 0000000000396970  /system/framework/framework.jar (offset 0x92b000) (android.os.Looper.loop+156)
      #55 pc 00000000003094d0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.7618685802058321727)+264) (BuildId: d0f321775158ed00df284edfabf672b6)
      #56 pc 0000000000311840  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #57 pc 0000000000312b9c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, true>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+1772) (BuildId: d0f321775158ed00df284edfabf672b6)
      #58 pc 0000000000178658  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<true, false>(art::interpreter::SwitchImplContext*)+58656) (BuildId: d0f321775158ed00df284edfabf672b6)
      #59 pc 000000000013f7d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: d0f321775158ed00df284edfabf672b6)
      #60 pc 00000000001a1698  /system/framework/framework.jar (android.app.ActivityThread.main)
      #61 pc 00000000003095d8  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.7618685802058321727)+528) (BuildId: d0f321775158ed00df284edfabf672b6)
      #62 pc 00000000006740c0  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+776) (BuildId: d0f321775158ed00df284edfabf672b6)
      #63 pc 000000000013cff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: d0f321775158ed00df284edfabf672b6)
      #64 pc 00000000001337e8  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: d0f321775158ed00df284edfabf672b6)
      #65 pc 00000000001a9804  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+228) (BuildId: d0f321775158ed00df284edfabf672b6)
      #66 pc 000000000055ce14  /apex/com.android.art/lib64/libart.so (art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+1364) (BuildId: d0f321775158ed00df284edfabf672b6)
      #67 pc 00000000004dba28  /apex/com.android.art/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+48) (BuildId: d0f321775158ed00df284edfabf672b6)
      #68 pc 00000000000896f4  /apex/com.android.art/javalib/arm64/boot.oat (art_jni_trampoline+180) (BuildId: 13577ce71153c228ecf0eb73fc39f45010d487f8)
      #69 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d0f321775158ed00df284edfabf672b6)
      #70 pc 00000000001a97e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #71 pc 000000000031c040  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: d0f321775158ed00df284edfabf672b6)
      #72 pc 0000000000312228  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+912) (BuildId: d0f321775158ed00df284edfabf672b6)
      #73 pc 00000000006856c0  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+848) (BuildId: d0f321775158ed00df284edfabf672b6)
      #74 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #75 pc 000000000044930a  /system/framework/framework.jar (offset 0x125d000) (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+22)
      #76 pc 00000000003094d0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.7618685802058321727)+264) (BuildId: d0f321775158ed00df284edfabf672b6)
      #77 pc 00000000006740c0  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+776) (BuildId: d0f321775158ed00df284edfabf672b6)
      #78 pc 000000000013cff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: d0f321775158ed00df284edfabf672b6)
      #79 pc 0000000000897668  /system/framework/arm64/boot-framework.oat (com.android.internal.os.ZygoteInit.main+2280) (BuildId: da25c976c2d1d3af123868772655a0779f8f6a48)
      #80 pc 00000000001337e8  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: d0f321775158ed00df284edfabf672b6)
      #81 pc 00000000001a9804  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+228) (BuildId: d0f321775158ed00df284edfabf672b6)
      #82 pc 000000000055b830  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+448) (BuildId: d0f321775158ed00df284edfabf672b6)
      #83 pc 000000000055bcf4  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+92) (BuildId: d0f321775158ed00df284edfabf672b6)
      #84 pc 000000000043ecbc  /apex/com.android.art/lib64/libart.so (art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+652) (BuildId: d0f321775158ed00df284edfabf672b6)
      #85 pc 000000000009948c  /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+124) (BuildId: 30f3430e4d2a28be49d3c60d623f0a29)
      #86 pc 00000000000a0a0c  /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+844) (BuildId: 30f3430e4d2a28be49d3c60d623f0a29)
      #87 pc 0000000000003570  /system/bin/app_process64 (main+1320) (BuildId: d4686d3f8282764488eb9ca7cc518583)
      #88 pc 00000000000495b4  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: c78cdff5b820a550771130d6bde95081)
Lost connection to device.

Environment

  • Kotlin 1.5.20
  • Flutter 2.2.3
  • DeepAR 2.4.1
  • CameraX 1.1.0-alpha07 / 1.0.0-alpha27

Additional notes

I see this error when running a Flutter App with Flutter Plugin on an Android Emulator (API Level 30) and on a real Android Device (Pixel 2, Android 11). I see this error when running the Flutter App in Debug-Mode and in Release-Mode.

Any help or any suggestions are very welcome. I'm quit new to Flutter and Android-Development, so there is a good chance I may have missed some important aspects.

Ar Preparation Issue

Ar instance creation taking time and first time launch throws error sometimes the activity not opening!

Fatal signal 7 (SIGBUS), code 1, fault addr 0xb93f4968 in tid 26455

I encounter a crash with HTC M8 (OS 6.0).

I just see some log with this...

E/Looper: Invalid attempt to set NULL callback but not allowed for this looper.
E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb91fc078
A/libc: Fatal signal 7 (SIGBUS), code 1, fault addr 0xb93f4968 in tid 26455

If I remove DeepAR.setRenderSurface(), it would not crash.
I think it crash in the aar file.

Integrate with Ant Media Server (AMS)

Hi,

I'm new in Android and JAVA and want to build a live streaming app with beauty & background segmentation & so on features by using Deep AR. I already subscribe Ant Media Server(AMS) as live streaming server and it work by refer their sample code and sdk here without Deep AR.

Now, I wish to integrate Deep AR into AMS. I has also refer another sample code here but doesn't work.

App is opened and live is started but there is no effect on live streaming and crash within few seconds. I try found problem at logcat section but no clue because too many messages. Below are the code I tried but failed:

// code within MainActivity.onCreate()
// first initialise deep AR
deepar = new DeepAR(this);
deepar.setLicenseKey("xxxxxx"); // please get from Deep AR
deepar.initialize(this, this); // second param please implements AREventListener

setupCamera(); // just copy from Deep AR sample code

arView = findViewById(R.id.surface); // using SurfaceViewRenderer ready by AMS
arView.getHolder().addCallback(this); // 'this' must implements 'SurfaceHolder.Callback'

// here setup AMS webRTC, it won't work with Deep AR
// or Deep AR will work if remove these part
webRTCClient = new WebRTCClient(this, this); // first param 'this' must implements IWebRTCListener
webRTCClient.setOpenFrontCamera(lensFacing == CameraSelector.LENS_FACING_FRONT);
webRTCClient.setVideoRenderers(null, arView);
Intent intent = getIntent(); // please refer sample code to add putExtra()
webRTCClient.init("ws://AMS IP", "RandomString", IWebRTCClient.MODE_PUBLISH, "tokenId", intent);
webRTCClient.setDataChannelObserver(this); // 'this' must implements IDataChannelObserver
new Handler(Looper.myLooper()).postDelayed(new Runnable() {
    @Override
    public void run() {
        attempt2Reconnect(); // please copy from AMS sample code
    }
}, 500);

Others important parts only, please copy all @OverRide method from sample code

@Override
public void initialized() {
    deepar.switchEffect("background", "file:///android_asset/background_segmentation"); // please download sample from Deep AR
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
    deepar.setRenderSurface(holder.getSurface(), width, height);
}

Did anyone success to integrate Deep AR into AMS? Please help. Another sample code got using Agora as media server but it is too expensive and I wish to self host server.

Thanks.

Example crashes

Hi!
I have an issue when trying to run example from https://developer.deepar.ai/downloads (3.1.0).

2021-08-23 18:43:33.267 18204-18204/ai.deepar.deepar_example E/linker: library "/system/lib64/libOpenCL.so" ("/system/lib64/libOpenCL.so") needed or dlopened by "/data/app/ai.deepar.deepar_example-Ogc6SefRwrp8FzgKw_MIJg==/lib/arm64/libnative-lib.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/ai.deepar.deepar_example-Ogc6SefRwrp8FzgKw_MIJg==/lib/arm64:/data/app/ai.deepar.deepar_example-Ogc6SefRwrp8FzgKw_MIJg==/base.apk!/lib/arm64-v8a", permitted_paths="/data:/mnt/expand:/data/data/ai.deepar.deepar_example"]
2021-08-23 18:43:33.996 18204-18204/ai.deepar.deepar_example A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 18204 (.deepar_example)

But when i comment deepAR.setRenderSurface it no longer has an issue.
On a project with previous versions of deepar.aar, It doesn't happen.

It works without problems on Google Pixel, but on Google Pixel 3 crashes.

Android Camera API 2 issue

When I'm trying to implement DeepAR using Camera API 2, the output comes black screen.

SDK version: DeepAR Android v2.3

Platform: Android

Code to reproduce:

import ai.deepar.ar.ARErrorType
import ai.deepar.ar.AREventListener
import ai.deepar.ar.DeepAR
import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.ImageFormat
import android.graphics.SurfaceTexture
import android.hardware.camera2.*
import android.hardware.camera2.params.StreamConfigurationMap
import android.media.Image
import android.media.ImageReader
import android.os.Bundle
import android.os.Handler
import android.os.HandlerThread
import android.util.Log
import android.util.Size
import android.util.SparseIntArray
import android.view.Surface
import android.view.TextureView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import java.io.*
import java.nio.ByteBuffer
import java.nio.ByteOrder
import java.util.*

class MainActivity : AppCompatActivity(), AREventListener {
    private var isFrontFacing: Boolean=true
    private var sensorOrientation: Int?=0
    private var textureView: TextureView? = null

    companion object {
        private const val TAG = "AndroidCameraApi"
        private val ORIENTATIONS: SparseIntArray = SparseIntArray()
        private const val REQUEST_CAMERA_PERMISSION = 200

        init {
            ORIENTATIONS.append(Surface.ROTATION_0, 90)
            ORIENTATIONS.append(Surface.ROTATION_90, 0)
            ORIENTATIONS.append(Surface.ROTATION_180, 270)
            ORIENTATIONS.append(Surface.ROTATION_270, 180)
        }
    }

    private lateinit var cameraManager: CameraManager
    private var cameraId: String? = null
    protected var cameraDevice: CameraDevice? = null
    protected var cameraCaptureSessions: CameraCaptureSession? = null
    protected var captureRequest: CaptureRequest? = null
    protected var captureRequestBuilder: CaptureRequest.Builder? = null
    private var imageDimension: Size? = null
    private var imageReader: ImageReader? = null
    private val file: File? = null
    private val mFlashSupported = false
    private var mBackgroundHandler: Handler? = null
    private var mBackgroundThread: HandlerThread? = null

    private lateinit var deepAR: DeepAR

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setTheme(R.style.Theme_AppCompat)
        setContentView(R.layout.camera_view)
        textureView = findViewById(R.id.texture)
        textureView!!.surfaceTextureListener = textureListener
        initializeDeepAR()
    }
    private fun initializeDeepAR() {
        deepAR = DeepAR(applicationContext)
        deepAR.setLicenseKey("-----LICENSE KEY----")
        deepAR.initialize(applicationContext, this)
    }

    private var textureListener: TextureView.SurfaceTextureListener = object : TextureView.SurfaceTextureListener {
        override fun onSurfaceTextureAvailable(surfaceTexture: SurfaceTexture?, width: Int, height: Int) {
            val surface = Surface(surfaceTexture)
            deepAR.setRenderSurface(surface, width, height)
            openCamera()
        }

        override fun onSurfaceTextureSizeChanged(surfaceTexture: SurfaceTexture?, width: Int, height: Int) {
            val surface = Surface(surfaceTexture)
            deepAR.setRenderSurface(surface, width, height)
        }

        override fun onSurfaceTextureDestroyed(surface: SurfaceTexture?): Boolean {
            deepAR.setRenderSurface(null, 0, 0)
            return false
        }

        override fun onSurfaceTextureUpdated(surface: SurfaceTexture?) {}
    }
    private val stateCallback: CameraDevice.StateCallback = object : CameraDevice.StateCallback() {
             override fun onOpened(camera: CameraDevice) {
            Log.e(TAG, "onOpened")
            cameraDevice = camera

            createCameraPreview()
        }

        override fun onDisconnected(camera: CameraDevice) {
            cameraDevice!!.close()
        }

        override fun onError(camera: CameraDevice, error: Int) {
            cameraDevice!!.close()
            cameraDevice = null
        }

    }
    val captureCallbackListener: CameraCaptureSession.CaptureCallback = object : CameraCaptureSession.CaptureCallback() {
//        fun onCaptureCompleted(session: CameraCaptureSession?, request: CaptureRequest?, result: TotalCaptureResult?) {
//            super.onCaptureCompleted(session, request, result)
//            Toast.makeText(this@AndroidCameraApi, "Saved:$file", Toast.LENGTH_SHORT).show()
//            createCameraPreview()
//        }

    }

    protected fun startBackgroundThread() {
        mBackgroundThread = HandlerThread("Camera Background")
        mBackgroundThread!!.start()
        mBackgroundHandler = Handler(mBackgroundThread!!.looper)
    }

    protected fun stopBackgroundThread() {
        mBackgroundThread!!.quitSafely()
        try {
            mBackgroundThread!!.join()
            mBackgroundThread = null
            mBackgroundHandler = null
        } catch (e: InterruptedException) {
            e.printStackTrace()
        }
    }
    private var currentBuffer = 0

    private fun createCameraPreview() {
        try {

            val texture: SurfaceTexture = textureView!!.surfaceTexture!!

            val width = imageDimension!!.width
            val height = imageDimension!!.height
            texture.setDefaultBufferSize(width, height)
//            val surface = Surface(texture)

            val imageReader = ImageReader.newInstance(width, height, ImageFormat.YUV_420_888, 2)
            imageReader.setOnImageAvailableListener({
                val img: Image = it.acquireLatestImage()

                val bytes: ByteArray
                val yBuffer: ByteBuffer = img.planes[0].buffer
                val uBuffer: ByteBuffer = img.planes[1].buffer
                val vBuffer: ByteBuffer = img.planes[2].buffer

                val ySize: Int = yBuffer.remaining()
                val uSize: Int = uBuffer.remaining()
                val vSize: Int = vBuffer.remaining()

                bytes = ByteArray(ySize + uSize + vSize)

                yBuffer.get(bytes, 0, ySize)
                vBuffer.get(bytes, ySize, vSize)
                uBuffer.get(bytes, ySize + vSize, uSize)

                val byteBuffer:ByteBuffer = ByteBuffer.allocateDirect(width * height * 3 / 2)
                byteBuffer.order(ByteOrder.nativeOrder())
                byteBuffer.position(0)

                // underflow
//                byteBuffer.put(yuvImageToByteArray(image = img))

                // green screen
                byteBuffer.put(ByteArray(width * height * 3 / 2))

                // overflow
//                byteBuffer.put(bytes)

                byteBuffer.position(0)

                deepAR.receiveFrame(byteBuffer, width, height, sensorOrientation!!, isFrontFacing)
                img.close()
            }, null)
            captureRequestBuilder = cameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_RECORD)
            captureRequestBuilder!!.addTarget(imageReader.surface)

            val surfaceList: MutableList<Surface> = ArrayList()
//            surfaceList.add(surface)
            surfaceList.add(imageReader.surface)
            cameraDevice!!.createCaptureSession(surfaceList, object : CameraCaptureSession.StateCallback() {
                override fun onConfigured(cameraCaptureSession: CameraCaptureSession) {
                    //The camera is already closed
                    Log.e(TAG, "configured")
                    if (null == cameraDevice) {
                        return
                    }
                    // When the session is ready, we start displaying the preview.
                    cameraCaptureSessions = cameraCaptureSession
                    updatePreview()
                }

                override fun onConfigureFailed(cameraCaptureSession: CameraCaptureSession) {
                    Toast.makeText(this@MainActivity, "Configuration fail", Toast.LENGTH_SHORT).show()
                }
            }, null)


        } catch (e: CameraAccessException) {
            e.printStackTrace()
        }
    }

    private fun yuvImageToByteArray(image: Image): ByteArray {
        if (BuildConfig.DEBUG && image.format != ImageFormat.YUV_420_888) {
            error("Assertion failed")
        }
        val width = image.width
        val height = image.height
        val planes = image.planes
        val result = ByteArray(width * height * 3 / 2)
        var stride = planes[0].rowStride
        if (BuildConfig.DEBUG && 1 != planes[0].pixelStride) {
            error("Assertion failed")
        }
        if (stride == width) {
            planes[0].buffer[result, 0, width * height]
        } else {
            for (row in 0 until height) {
                planes[0].buffer.position(row * stride)
                planes[0].buffer[result, row * width, width]
            }
        }
        stride = planes[1].rowStride
        if (BuildConfig.DEBUG && stride != planes[2].rowStride) {
            error("Assertion failed")
        }
        val pixelStride = planes[1].pixelStride
        if (BuildConfig.DEBUG && pixelStride != planes[2].pixelStride) {
            error("Assertion failed")
        }
        val rowBytesCb = ByteArray(stride)
        val rowBytesCr = ByteArray(stride)
        for (row in 0 until height / 2) {
            val rowOffset = width * height + width / 2 * row
            planes[1].buffer.position(row * stride)
            planes[1].buffer[rowBytesCb]
            planes[2].buffer.position(row * stride)
            planes[2].buffer[rowBytesCr]
            for (col in 0 until width / 2) {
                result[rowOffset + col * 2] = rowBytesCr[col * pixelStride]
                result[rowOffset + col * 2 + 1] = rowBytesCb[col * pixelStride]
            }
        }
        return result
    }

    private fun openCamera() {
        cameraManager = getSystemService(Context.CAMERA_SERVICE) as CameraManager
        try {
            cameraId = cameraManager.cameraIdList[1]
            val characteristics: CameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId!!)
            sensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION)
            isFrontFacing = (characteristics.get(CameraCharacteristics.LENS_FACING)
                    == CameraMetadata.LENS_FACING_FRONT)
            val map: StreamConfigurationMap = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)!!
            imageDimension = map.getOutputSizes(SurfaceTexture::class.java)[0]
            // Add permission for camera and let user grant the permission
            if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) !== PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(this@MainActivity, arrayOf(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE), REQUEST_CAMERA_PERMISSION)
                return
            }

            cameraManager.openCamera(cameraId!!, stateCallback, null)
        } catch (e: CameraAccessException) {
            e.printStackTrace()
        }
        Log.e(TAG, "openCamera X")
    }

    protected fun updatePreview() {
        Log.e(TAG, "update preview X")
        if (null == cameraDevice) {
            Log.e(TAG, "updatePreview error, return")
        }
        captureRequestBuilder!!.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO)
        try {
            cameraCaptureSessions!!.setRepeatingRequest(captureRequestBuilder!!.build(), null, mBackgroundHandler)
        } catch (e: CameraAccessException) {
            e.printStackTrace()
        }
    }

    private fun closeCamera() {
        if (null != cameraDevice) {
            cameraDevice!!.close()
            cameraDevice = null
        }
        if (null != imageReader) {
            imageReader!!.close()
            imageReader = null
        }
    }

    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String?>, grantResults: IntArray) {
        if (requestCode == REQUEST_CAMERA_PERMISSION) {
            if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
                // close the app
                Toast.makeText(this, "Sorry!!!, you can't use this app without granting permission", Toast.LENGTH_LONG).show()
                finish()
            }
        }
    }

    override fun onResume() {
        super.onResume()
        Log.e(TAG, "onResume")
        startBackgroundThread()
        if (textureView!!.isAvailable) {
            openCamera()
        } else {
            textureView!!.surfaceTextureListener = textureListener
        }
    }

    override fun onPause() {
        Log.e(TAG, "onPause")
        closeCamera();
        stopBackgroundThread()
        super.onPause()
    }

    override fun screenshotTaken(p0: Bitmap?) {
        
    }

    override fun videoRecordingStarted() {
        
    }

    override fun videoRecordingFinished() {
    }

    override fun videoRecordingFailed() {
        
    }

    override fun videoRecordingPrepared() {
        
    }

    override fun shutdownFinished() {

    }

    override fun initialized() {

    }

    override fun faceVisibilityChanged(p0: Boolean) {

    }

    override fun imageVisibilityChanged(p0: String?, p1: Boolean) {
    }

    override fun frameAvailable(p0: Image?) {

    }

    override fun error(p0: ARErrorType?, p1: String?) {
    }

    override fun effectSwitched(p0: String?) {
    }
}

Any solution to this problem?

Moto g62 model recorded video can't play

i have faced recorded video coming to black screen and can't play video.but mp4 file generated successfully in moto g62 android 12 version mobile.can u please help to fix this issue?

Camera API 2

Hi,
Please update the camera API 2 in CameraGrabber. because those of the camera methods now deprecated in this class.

Set License problem

No implementation found for void ai.deepar.ar.DeepAR.setLicenseKeyN(java.lang.String) (tried Java_ai_deepar_ar_DeepAR_setLicenseKeyN and Java_ai_deepar_ar_DeepAR_setLicenseKeyN__Ljava_lang_String_2)

Having issue in running the sample project

System config
Android Studio 3.6.1
Build #AI-192.7142.36.36.6241897, built on February 27, 2020
Runtime version: 1.8.0_212-release-1586-b04 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

The project is not compiling
FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
Could not find :deepar:.
Required by:
project :app

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 0s

as far as I think it is not able to get the deepar.aar library, how can I resolve this.

Crash on bindImageAnalysis

Fatal Exception: java.nio.BufferOverflowException
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:298)
at java.nio.ByteBuffer.put(ByteBuffer.java:732)
at com.hinotes.ui.createvideo.CreateVideoActivity$bindImageAnalysis$1.analyze
at androidx.camera.core.ImageAnalysis.lambda$setAnalyzer$2$ImageAnalysis(ImageAnalysis.java:450)
at androidx.camera.core.-$$Lambda$ImageAnalysis$-wcArnbkVmqkAHxpJ0VOR9b2w0Q.analyze(:4)
at androidx.camera.core.ImageAnalysisAbstractAnalyzer.lambda$analyzeImage$0$ImageAnalysisAbstractAnalyzer(ImageAnalysisAbstractAnalyzer.java:145)
at androidx.camera.core.-$$Lambda$ImageAnalysisAbstractAnalyzer$8nmjUxCmaK9ClOx3NHAdwtp6S3w.run(:10)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:250)
at android.app.ActivityThread.main(ActivityThread.java:7877)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)

Load a single image

Hello,
I can load a single image/Bitmap and apply a filter? Could I have an example?

Error : Invalid output width and/or height

After I traced code, I found that I set the surface width or height could bigger than MediaVideoEncoder.getMaxSupportedWidth or MediaVideoEncoder.getMaxSupportedHeight.
( deepAR.setRenderSurface(holder.surface, width, height) ).

So, I faced this Error (Invalid output width and/or height), and I cannot record video.

I suggest it could public those func MediaVideoEncoder.getMaxSupportedHeight() and MediaVideoEncoder.getMaxSupportedWidth() to use by me.

Thus, I think I will not face this issue.

Could not find :deepar

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find :deepar:.
Searched in the following locations:
- file:/Users/ahuja/Aexyn/DeepAR-quickstart-android-java/deepar/deepar.aar
Required by:
project :app

can anyone help where can I get deepar.aar file ? its not there in code

Video feed not starting on Samsung devices

Today I tried your quickstart project in Android Studio. I was able to start the camera feed on an Honor 7 phone, but I was unable to start the camera feed on Samsung devices.

Steps to reproduce issue

  • Pull the quickstart-android-java repository
  • Download and install Android Studio version 2022.2.1
  • Create a project with bundle id: com.simontest.deeparandroid
  • Add the application id at line 6 in app/build.gradle
  • Add the license key at line 340 in app\src\main\java\ai\deepar\deepar_example\MainActivity.java
  • Press file -> Sync Project with gradle files
  • Connect the device
  • Build the application to the device

Symptoms:

  • Camera feed stays black, unable to use UI.

Devices working

  • Honor 7

Devices not working

  • Samsung Galaxy A52 Android version 13
  • Samsung Galaxy S20 Android version 13

Dynamic filters

How can i switch mask on face from the server link (dynamic filter on our server)
is the DeepAR support dynamic filter?

Camera2 api

Do you have any examples of how we can use the DeepAR SDK with the Camera2 api?

Documentation issue - Specify supported Android studio version

I am currently trying to get the Android demo project working. When building the project the following error message is displayed:

The project is using an incompatible version (AGP 8.0.2) of the Android Gradle plugin. Latest supported version is AGP 7.4.1

This is probably due to me using an older version of Android studio. However, the Readme.md in this repository does not specify any Android Studio version.

Can you update the readme, so the used Android studio version for this is specified?

Proguard Issue

I have used the proguard rule as explained in our Getting started guide: but still it crashes with the error on starting activity with this error -

JNI DETECTED ERROR IN APPLICATION: JNI GetMethodID called with pending exception java.lang.ClassNotFoundException: Didn't find class "ai.deepar.ar.core.videotexture.VideoTextureAndroidJava" on path: DexPathList[[zip file "/data/app/~~T0pVT48GzNIr9uQzPc0srA==/ai.deepar.deepar_example-uczsvnBAQAk-l1uKVWPWAg==/base.apk"],nativeLibraryDirectories=[/data/app/~~T0pVT48GzNIr9uQzPc0srA==/ai.deepar.deepar_example-uczsvnBAQAk-l1uKVWPWAg==/lib/arm64, /data/app/~~T0pVT48GzNIr9uQzPc0srA==/ai.deepar.deepar_example-uczsvnBAQAk-l1uKVWPWAg==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]

To recreate the issue add proguard in the debug version like this -

debug {
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}

Unable to update texture contents

2021-12-22 08:31:08.474 5969-5969/ai.deepar.deepar_example E/AndroidRuntime: FATAL EXCEPTION: main
Process: ai.deepar.deepar_example, PID: 5969
java.lang.IllegalStateException: Unable to update texture contents (see logcat for details)
at android.graphics.SurfaceTexture.nativeUpdateTexImage(Native Method)
at android.graphics.SurfaceTexture.updateTexImage(SurfaceTexture.java:243)
at ai.deepar.deepar_example.ARSurfaceProvider.lambda$onSurfaceRequested$0$ARSurfaceProvider(ARSurfaceProvider.java:66)
at ai.deepar.deepar_example.-$$Lambda$ARSurfaceProvider$JAipkCmqGxwLcfXLPwXbYnzYXAQ.onFrameAvailable(Unknown Source:4)
at android.graphics.SurfaceTexture$1.handleMessage(SurfaceTexture.java:206)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6543)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.