简体   繁体   中英

Building librealsense android app with NDK (native c++ code) part?

I'm trying to build an android app.

  1. The app utilizes librealsense android wrapper to get frames (which returns com.intel.realsense.librealsense.FrameSet ).
  2. It then passes the obtained frames to some native C++ functions for further processing. The native C++ functions takes rs2::frameset as input argument, eg int NativeFrameProcessing(rs2::frameset& frames) . This is achieved by using NDK.

By looking at the librealsense sample android programs, the frame acquisition part in android seems quite clear. And also the librealsense code has shown passing frames to native part by converting native pointers to jlong .

What I'm not clear with, is how to specify the librealsense dependencies in both the android part and the NDK (native code) part.

In android, the dependency is specified as:

repositories {
    maven{
        url "https://dl.bintray.com/intel-realsense/librealsense-dev"
    }
}

dependencies {
    implementation 'com.intel.realsense:librealsense:2.41.0+@aar'
}

In NDK (native code part), I use CMake to generate compile configurations.

find_package(realsense2 REQUIRED)

But I guess in this way, CMake would find the librealsense that is installed in the current system (Ubuntu in this case as I'm doing the project in Ubuntu), which is not built against android devices, and the version may not be consistent with the downloaded AAR android library.

So how can I correctly specify the dependencies to librealsense? For example, pointing CMake to somehow use the downloaded AAR library so both the android part and NDK part depends on the same librealsense? Thanks in advance !

According to the Android documentation , the AAR already contains the native assembly -
which means, that you don't need to build it and that you could remove CMake support.

In case you may want to build the AAR by yourself, just follow the build instructions .

And if, for whatever reason, you may want to link against realsense2.so directly, you could simply extract it from the AAR by unzipping it - or build the AAR by yourself and grab it from the outputs.

The toolchain will most definitely not care about assembly installed on the host system - and even if both may produce x86_64 assembly, they'd be linked against different libraries and are therefore incompatible and not interchangeable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM