Skip to content

Commit

Permalink
Merge pull request #3869 from matkatz/android-filter-option
Browse files Browse the repository at this point in the history
Android - add missing filters to Java API
  • Loading branch information
dorodnic authored Apr 30, 2019
2 parents d02697f + 2354cba commit 6648579
Show file tree
Hide file tree
Showing 27 changed files with 773 additions and 11 deletions.
12 changes: 12 additions & 0 deletions src/android/jni/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ Java_com_intel_realsense_librealsense_Points_nGetCount(JNIEnv *env, jclass type,
return rv;
}

extern "C"
JNIEXPORT void JNICALL
Java_com_intel_realsense_librealsense_Points_nExportToPly(JNIEnv *env, jclass type, jlong handle,
jstring filePath_, jlong textureHandle) {
const char *filePath = env->GetStringUTFChars(filePath_, 0);
rs2_error *e = NULL;
rs2_export_to_ply(reinterpret_cast<const rs2_frame *>(handle), filePath,
reinterpret_cast<rs2_frame *>(textureHandle), &e);
handle_error(env, e);
env->ReleaseStringUTFChars(filePath_, filePath);
}

extern "C" JNIEXPORT jdouble JNICALL
Java_com_intel_realsense_librealsense_Frame_nGetTimestamp(JNIEnv *env, jclass type, jlong handle) {
rs2_error *e = NULL;
Expand Down
110 changes: 103 additions & 7 deletions src/android/jni/processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ Java_com_intel_realsense_librealsense_ProcessingBlock_nDelete(JNIEnv *env, jclas
rs2_delete_processing_block(reinterpret_cast<rs2_processing_block *>(handle));
}

extern "C" JNIEXPORT void JNICALL
Java_com_intel_realsense_librealsense_ProcessingBlock_nInvoke(JNIEnv *env, jclass type,
jlong handle, jlong frameHandle) {
rs2_error *e = NULL;
rs2_frame_add_ref(reinterpret_cast<rs2_frame *>(frameHandle), &e);
handle_error(env, e);
rs2_process_frame(reinterpret_cast<rs2_processing_block *>(handle),
reinterpret_cast<rs2_frame *>(frameHandle), &e);
handle_error(env, e);
}

extern "C"
JNIEXPORT jlong JNICALL
Java_com_intel_realsense_librealsense_Align_nCreate(JNIEnv *env, jclass type, jlong queueHandle,
jint alignTo) {
rs2_error *e = NULL;
rs2_processing_block *rv = rs2_create_align(static_cast<rs2_stream>(alignTo), &e);
handle_error(env, e);
rs2_start_processing_queue(rv, reinterpret_cast<rs2_frame_queue *>(queueHandle), &e);
handle_error(env, e);
return reinterpret_cast<jlong>(rv);
}

extern "C" JNIEXPORT jlong JNICALL
Java_com_intel_realsense_librealsense_Colorizer_nCreate(JNIEnv *env, jclass type, jlong queueHandle) {
rs2_error *e = NULL;
Expand All @@ -23,7 +46,7 @@ Java_com_intel_realsense_librealsense_Colorizer_nCreate(JNIEnv *env, jclass type
}

extern "C" JNIEXPORT jlong JNICALL
Java_com_intel_realsense_librealsense_Decimation_nCreate(JNIEnv *env, jclass type,
Java_com_intel_realsense_librealsense_DecimationFilter_nCreate(JNIEnv *env, jclass type,
jlong queueHandle) {
rs2_error *e = NULL;
rs2_processing_block *rv = rs2_create_decimation_filter_block(&e);
Expand All @@ -33,13 +56,86 @@ Java_com_intel_realsense_librealsense_Decimation_nCreate(JNIEnv *env, jclass typ
return reinterpret_cast<jlong>(rv);
}

extern "C" JNIEXPORT void JNICALL
Java_com_intel_realsense_librealsense_ProcessingBlock_nInvoke(JNIEnv *env, jclass type,
jlong handle, jlong frameHandle) {
extern "C"
JNIEXPORT jlong JNICALL
Java_com_intel_realsense_librealsense_DisparityTransformFilter_nCreate(JNIEnv *env, jclass type,
jlong queueHandle,
jboolean transformToDisparity) {
rs2_error *e = NULL;
rs2_frame_add_ref(reinterpret_cast<rs2_frame *>(frameHandle), &e);
rs2_processing_block *rv = rs2_create_disparity_transform_block(transformToDisparity, &e);
handle_error(env, e);
rs2_process_frame(reinterpret_cast<rs2_processing_block *>(handle),
reinterpret_cast<rs2_frame *>(frameHandle), &e);
rs2_start_processing_queue(rv, reinterpret_cast<rs2_frame_queue *>(queueHandle), &e);
handle_error(env, e);
return reinterpret_cast<jlong>(rv);
}

extern "C"
JNIEXPORT jlong JNICALL
Java_com_intel_realsense_librealsense_HoleFillingFilter_nCreate(JNIEnv *env, jclass type,
jlong queueHandle) {
rs2_error *e = NULL;
rs2_processing_block *rv = rs2_create_hole_filling_filter_block(&e);
handle_error(env, e);
rs2_start_processing_queue(rv, reinterpret_cast<rs2_frame_queue *>(queueHandle), &e);
handle_error(env, e);
return reinterpret_cast<jlong>(rv);
}

extern "C"
JNIEXPORT jlong JNICALL
Java_com_intel_realsense_librealsense_Pointcloud_nCreate(JNIEnv *env, jclass type,
jlong queueHandle) {
rs2_error *e = NULL;
rs2_processing_block *rv = rs2_create_pointcloud(&e);
handle_error(env, e);
rs2_start_processing_queue(rv, reinterpret_cast<rs2_frame_queue *>(queueHandle), &e);
handle_error(env, e);
return reinterpret_cast<jlong>(rv);
}

extern "C"
JNIEXPORT jlong JNICALL
Java_com_intel_realsense_librealsense_SpatialFilter_nCreate(JNIEnv *env, jclass type, jlong queueHandle) {
rs2_error *e = NULL;
rs2_processing_block *rv = rs2_create_spatial_filter_block(&e);
handle_error(env, e);
rs2_start_processing_queue(rv, reinterpret_cast<rs2_frame_queue *>(queueHandle), &e);
handle_error(env, e);
return reinterpret_cast<jlong>(rv);
}

extern "C"
JNIEXPORT jlong JNICALL
Java_com_intel_realsense_librealsense_TemporalFilter_nCreate(JNIEnv *env, jclass type,
jlong queueHandle) {
rs2_error *e = NULL;
rs2_processing_block *rv = rs2_create_temporal_filter_block(&e);
handle_error(env, e);
rs2_start_processing_queue(rv, reinterpret_cast<rs2_frame_queue *>(queueHandle), &e);
handle_error(env, e);
return reinterpret_cast<jlong>(rv);
}

extern "C"
JNIEXPORT jlong JNICALL
Java_com_intel_realsense_librealsense_ThresholdFilter_nCreate(JNIEnv *env, jclass type,
jlong queueHandle) {
rs2_error *e = NULL;
rs2_processing_block *rv = rs2_create_threshold(&e);
handle_error(env, e);
rs2_start_processing_queue(rv, reinterpret_cast<rs2_frame_queue *>(queueHandle), &e);
handle_error(env, e);
return reinterpret_cast<jlong>(rv);
}

extern "C"
JNIEXPORT jlong JNICALL
Java_com_intel_realsense_librealsense_ZeroOrderInvalidationFilter_nCreate(JNIEnv *env, jclass type,
jlong queueHandle) {
rs2_error *e = NULL;
rs2_processing_block *rv = rs2_create_zero_order_invalidation_block(&e);
handle_error(env, e);
rs2_start_processing_queue(rv, reinterpret_cast<rs2_frame_queue *>(queueHandle), &e);
handle_error(env, e);
return reinterpret_cast<jlong>(rv);
}
1 change: 1 addition & 0 deletions wrappers/android/examples/processing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
29 changes: 29 additions & 0 deletions wrappers/android/examples/processing/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.intel.realsense.processing"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':librealsense')
}
21 changes: 21 additions & 0 deletions wrappers/android/examples/processing/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
24 changes: 24 additions & 0 deletions wrappers/android/examples/processing/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.intel.realsense.processing">

<uses-permission android:name="android.permission.CAMERA"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="com.intel.realsense.processing.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading

0 comments on commit 6648579

Please sign in to comment.