Skip to content

orbbec/OrbbecSDK-Android-Wrapper

 
 

Repository files navigation

Introduction

The v2-main branch provides an Android wrapper based on the Orbbec SDK v2.x. Orbbec SDK v2.x is an open-source, cross-platform SDK for interfacing with Orbbec RGB-D cameras. For a comparison between SDK v2.x and Orbbec SDK v1.x, see the README.

Additionally, a comprehensive overview of the API changes from Android Wrapper v1.x to v2.x can be found here: api_changes_at_v2.x.

Important

Welcome to the Android wrapper . Before you begin using this version of Android wrapper , it's crucial to check the following device support list to verify the compatibility.

Here is the device support list of main branch (v1.x) and v2-main branch (v2.x):

Product Series Product Branch main Branch v2-main
Gemini 330 Gemini 335 full maintenance recommended for new designs
Gemini 336 full maintenance recommended for new designs
Gemini 330 full maintenance recommended for new designs
Gemini 335L full maintenance recommended for new designs
Gemini 336L full maintenance recommended for new designs
Gemini 330L full maintenance recommended for new designs
Gemini 2 Gemini 2 full maintenance recommended for new designs
Gemini 2 L full maintenance recommended for new designs
Gemini 210 not supported recommended for new designs
Gemini 215 not supported recommended for new designs
Gemini 2 XL recommended for new designs to be supported
Astra Astra 2 full maintenance recommended for new designs
Astra+ limited maintenance not supported
Astra Pro Plus limited maintenance not supported
Astra Mini Astra Mini Pro full maintenance not supported

Note: If you do not find your device, please contact our FAE or sales representative for help.

Definition:

  1. recommended for new designs: we will provide full supports with new features, bug fix and performance optimization;
  2. full maintenance: we will provide bug fix support;
  3. limited maintenance: we will provide critical bug fix support;
  4. not supported: we will not support specific device in this version;
  5. to be supported: we will add support in the near future.

Hardware Products Supported by Android SDK

Products List Minimal Firmware Version
Gemini 330 1.2.20
Gemini 330L 1.2.20
Gemini 335 1.2.20
Gemini 335L 1.2.20
Gemini 336 1.2.20
Gemini 336L 1.2.20
Astra 2 2.8.20
Gemini 2 L 1.4.53
Gemini 2 1.4.92
Gemini 215 1.0.9
Gemini 210 1.0.9

import project

  1. Open Android studio
  2. Menu: File --> open, and select project directory
  3. Click Ok button
  4. wait gradle sync complete

run example

build example

Click run button

Main UI

Click 'Basic-Quick Start' to display the color and depth sensor streams.

QuickStart

Depth

MultiStreams

Build Tools

Android studio

Android studio Koala | 2024.1.1 download link Android studio

NDK

version: 27.2.12479018

CMake

version: 3.18.1

gradle

gradle/wrapper/gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip

gradle pulgins

build.gradle

plugins {
id 'com.android.application' version '8.1.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
    id 'com.android.library' version '8.1.0' apply false
}

library and example

sensorsdk

Orbbec basic sdk implementation with c & cpp, android wrapper import sensorsdk as so.

so files

path: obsensor_jni/libs

include headers

path: obsensor_jni/src/main/cpp/sensorsdk

Note: To short include path in native code, module of 'obsensor_jni' import as path 'obsensor_jni/src/main/cpp/sensorsdk/include/libobsensor'

obsensor_jni

Android wrapper implementation with jni which is forward or transfer data between java and native sensorsdk.

Support android version

  • Test on the Android 13
  • Note: If using Android 10, set targetSdk to 27
minSdk 24
//noinspection ExpiredTargetSdkVersion
targetSdk 27

Simple code of open depth stream

Create OBContext global member to manager attach devices

// Application hold only one OBContext instance.
private OBContext mOBContext;
private Object mCurrentDeviceLock = new Object();
private Device mCurrentDevice;
private DeviceInfo mCurrentDeviceInfo;

Initialize OBContext with DeviceChangedCallback

mOBContext = new OBContext(getApplicationContext(), new DeviceChangedCallback() {
   @Override
   public void onDeviceAttach(DeviceList deviceList) {
        try {
            mCurrentDevice = deviceList.getDevice(0);
            mCurrentDeviceInfo = mCurrentDevice.getInfo();
            deviceList.close();
            // do something
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            deviceList.close();
        }
   }

   @Override
   public void onDeviceDetach(DeviceList deviceList) {
         try {
            if (null != mCurrentDevice){
                int deviceCount = deviceList.getDeviceCount();
                    for(int i = 0; i < deviceCount; i++){
                        String uid = deviceList.getUid();
                        if(null != mCurrentDeviceInfo && mCurrentDeviceInfo.getUid().equals(uid)){
                            // handle device disconnection
                            // do something

                            Log.d("Orbbec","Device disconnection. name: "+mCurrentDeviceInfo.getName()+", uid: "+mCurrentDeviceInfo.getUid());
                            mCurrentDevice.close();
                            mCurrentDevice=null;
                        }
                    }
            }
         } catch (Exception e) {
            e.printStackTrace();
         } finally {
            deviceList.close();
        }
   }
});

Define Pipeline and Device

private Pipeline mPipeline;

Start Depth stream

try {
   mPipeline = new Pipeline(mCurrentDevice);

   StreamProfileList depthProfileList = mPipeline.getStreamProfileList(SensorType.DEPTH);
   if (null == depthProfileList) {
      return;
   }
   StreamProfile streamProfile = depthProfileList.getStreamProfile(0);
   Config config = new Config();
   config.enableStream(streamProfile);
   streamProfile.close();
   depthProfileList.close();

   mPipeline.start(config, new FrameSetCallback() {
      public void onFrameSet(FrameSet frameSet) {
         DepthFrame depthFrame = frameSet.getDepthFrame()
         if (null != depthFrame) {
            Log.d("Orbbec", "onFrameSet depthFrame index: " + depthFrame.getFrameIndex() + ", timeStamp: " + depthFrame.getTimeStamp());

            // do Render

            depthFrame.close();
         }
      }
   });
   config.close();
} catch (OBException e) {
   e.printStackTrace();
}

Stop stream

try {
   mPipeline.stop();
} catch (OBException e) {
   e.printStackTrace();
}

Close device

try {
   if (null != mPipeline) {
      mPipeline.close();
   }

   if (mDevice != null) {
      mDevice.close();
   }
} catch (OBException e) {
   e.printStackTrace();
}

QA

LintModelSeverity has been compiled by a more recent version of the Java

An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
   > Could not create an instance of type com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated.
      > Could not create an instance of type com.android.build.gradle.internal.dsl.LintImpl$AgpDecorated.
         > Could not generate a decorated class for type LintImpl$AgpDecorated.
            > com/android/tools/lint/model/LintModelSeverity has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

Reason: AGP(android gradle plugin) is v8.1.0, need jdk 17, Please update android studio to new version, and check gradle jdk version. Android studio --> File --> Settings --> Build,Execution,Deployment --> Build Tools --> Gradle, check Gradle Projects -> Gradle JDK

reference: https://developer.android.com/studio/releases#android_gradle_plugin_and_android_studio_compatibility

https://developer.android.com/build/releases/gradle-plugin

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors