feat(android): add types and interfaces
This commit is contained in:
1
wrappers/android/mynteye/scripts/.gitignore
vendored
1
wrappers/android/mynteye/scripts/.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/djinni-output-temp/
|
||||
/*.yaml
|
||||
@@ -1,33 +1,33 @@
|
||||
@extern "mynteye_types.yaml"
|
||||
|
||||
format = enum {
|
||||
grey;
|
||||
yuyv;
|
||||
bgr888;
|
||||
rgb888;
|
||||
}
|
||||
|
||||
stream_request = record {
|
||||
index: i32;
|
||||
width: i32;
|
||||
height: i32;
|
||||
format: format;
|
||||
fps: i32;
|
||||
}
|
||||
|
||||
device_usb_info = record {
|
||||
index: i32;
|
||||
name: string;
|
||||
sn: string;
|
||||
}
|
||||
|
||||
# Device class to communicate with MYNT® EYE device
|
||||
device = interface +c {
|
||||
# Query devices
|
||||
static query(): list<device_usb_info>;
|
||||
|
||||
# Create the device instance
|
||||
static create(info: device_usb_info): device;
|
||||
|
||||
# Get all stream requests
|
||||
get_stream_requests(): list<stream_request>;
|
||||
# Config the stream request
|
||||
config_stream_request(request: stream_request);
|
||||
|
||||
start();
|
||||
stop();
|
||||
# Start capturing the source
|
||||
start(source: source);
|
||||
# Stop capturing the source
|
||||
stop(source: source);
|
||||
|
||||
# Wait the streams are ready
|
||||
wait_for_streams();
|
||||
|
||||
# Get the latest data of stream
|
||||
get_stream_data(stream: stream): stream_data;
|
||||
# Get the datas of stream
|
||||
get_stream_datas(stream: stream): list<stream_data>;
|
||||
|
||||
# Enable cache motion datas
|
||||
enable_cache_motion_datas(max_size: i32);
|
||||
# Get the motion datas
|
||||
get_motion_datas(): list<motion_data>;
|
||||
}
|
||||
|
||||
119
wrappers/android/mynteye/scripts/mynteye_types.djinni
Normal file
119
wrappers/android/mynteye/scripts/mynteye_types.djinni
Normal file
@@ -0,0 +1,119 @@
|
||||
|
||||
# Device USB information
|
||||
device_usb_info = record {
|
||||
# Device index
|
||||
index: i32;
|
||||
# Device name
|
||||
name: string;
|
||||
# Device serial number
|
||||
sn: string;
|
||||
}
|
||||
|
||||
# Device model
|
||||
model = enum {
|
||||
# Standard
|
||||
standard;
|
||||
# Standard 2
|
||||
standard2;
|
||||
# Standard 210a
|
||||
standard210a;
|
||||
}
|
||||
|
||||
# Formats define how each stream can be encoded
|
||||
format = enum {
|
||||
# Greyscale, 8 bits per pixel
|
||||
grey;
|
||||
# YUV 4:2:2, 16 bits per pixel
|
||||
yuyv;
|
||||
# BGR 8:8:8, 24 bits per pixel
|
||||
bgr888;
|
||||
# RGB 8:8:8, 24 bits per pixel
|
||||
rgb888;
|
||||
}
|
||||
|
||||
# Stream request
|
||||
stream_request = record {
|
||||
# Stream index
|
||||
index: i32;
|
||||
# Stream width in pixels
|
||||
width: i32;
|
||||
# Stream height in pixels
|
||||
height: i32;
|
||||
# Stream pixel format
|
||||
format: format;
|
||||
# Stream frames per second
|
||||
fps: i32;
|
||||
}
|
||||
|
||||
# Source allows the user to choose which data to be captured
|
||||
source = enum {
|
||||
# Video streaming of stereo, color, depth, etc.
|
||||
video_streaming;
|
||||
# Motion tracking of IMU (accelerometer, gyroscope)
|
||||
motion_tracking;
|
||||
# Enable everything together
|
||||
all;
|
||||
}
|
||||
|
||||
# Streams define different type of data
|
||||
stream = enum {
|
||||
# Left stream
|
||||
left;
|
||||
# Right stream
|
||||
right;
|
||||
}
|
||||
|
||||
# Frame with raw data
|
||||
frame = interface +c {
|
||||
# Get the width
|
||||
width(): i32;
|
||||
# Get the height
|
||||
height(): i32;
|
||||
# Get the pixel format
|
||||
format(): format;
|
||||
# Get the size
|
||||
size(): i32;
|
||||
# Get the data
|
||||
data(): binary;
|
||||
}
|
||||
|
||||
# Image data
|
||||
img_data = record {
|
||||
# Image frame id
|
||||
frame_id: i64;
|
||||
# Image timestamp in 1us
|
||||
timestamp: i64;
|
||||
# Image exposure time, virtual value in [1, 480]
|
||||
exposure_time: i64;
|
||||
}
|
||||
|
||||
# IMU data
|
||||
imu_data = record {
|
||||
# IMU frame id
|
||||
frame_id: i64;
|
||||
# IMU accel or gyro flag
|
||||
# 0: accel and gyro are both valid
|
||||
# 1: accel is valid
|
||||
# 2: gyro is valid
|
||||
flag: i32;
|
||||
# IMU timestamp in 1us
|
||||
timestamp: i64;
|
||||
# IMU accelerometer data for 3-axis: X, Y, Z.
|
||||
accel: list<f64>;
|
||||
# IMU gyroscope data for 3-axis: X, Y, Z.
|
||||
gyro: list<f64>;
|
||||
# IMU temperature
|
||||
temperature: f64;
|
||||
}
|
||||
|
||||
# Device stream data
|
||||
stream_data = interface +c {
|
||||
img(): img_data;
|
||||
frame(): frame;
|
||||
frame_id(): i64;
|
||||
}
|
||||
|
||||
# Device motion data
|
||||
motion_data = interface +c {
|
||||
imu(): imu_data;
|
||||
}
|
||||
@@ -6,11 +6,10 @@ base_dir=$(cd "$(dirname "$0")" && pwd)
|
||||
|
||||
# options
|
||||
|
||||
while getopts "d:i:" opt; do
|
||||
while getopts "d:" opt; do
|
||||
case "$opt" in
|
||||
d) djinni_dir="$OPTARG" ;;
|
||||
i) in_idl="$OPTARG" ;;
|
||||
?) echo "Usage: $0 <-d DJINNI_DIR> [-i IN_IDL]"
|
||||
?) echo "Usage: $0 <-d DJINNI_DIR>"
|
||||
exit 2 ;;
|
||||
esac
|
||||
done
|
||||
@@ -20,8 +19,6 @@ if [ -z "$djinni_dir" ]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
[ -n "$in_idl" ] || in_idl="$base_dir/mynteye.djinni"
|
||||
|
||||
# generate
|
||||
|
||||
djinni_run="$djinni_dir/src/run-assume-built"
|
||||
@@ -36,25 +33,35 @@ java_package="com.slightech.mynteye"
|
||||
cpp_namespace="mynteye_jni"
|
||||
|
||||
[ ! -e "$temp_out" ] || rm -r "$temp_out"
|
||||
"$djinni_run" \
|
||||
--java-out "$temp_out/java" \
|
||||
--java-package "$java_package" \
|
||||
--java-class-access-modifier "public" \
|
||||
--java-generate-interfaces true \
|
||||
--java-nullable-annotation "androidx.annotation.Nullable" \
|
||||
--java-nonnull-annotation "androidx.annotation.NonNull" \
|
||||
--ident-java-field mFooBar \
|
||||
\
|
||||
--cpp-out "$temp_out/cpp" \
|
||||
--cpp-namespace "$cpp_namespace" \
|
||||
--ident-cpp-enum-type FooBar \
|
||||
--ident-cpp-method FooBar \
|
||||
\
|
||||
--jni-out "$temp_out/jni" \
|
||||
--ident-jni-class NativeFooBar \
|
||||
--ident-jni-file NativeFooBar \
|
||||
\
|
||||
--idl "$in_idl"
|
||||
|
||||
djinni_build() {
|
||||
local in_idl="$1"; shift
|
||||
"$djinni_run" \
|
||||
--java-out "$temp_out/java" \
|
||||
--java-package "$java_package" \
|
||||
--java-class-access-modifier "public" \
|
||||
--java-generate-interfaces true \
|
||||
--java-nullable-annotation "androidx.annotation.Nullable" \
|
||||
--java-nonnull-annotation "androidx.annotation.NonNull" \
|
||||
--ident-java-field mFooBar \
|
||||
\
|
||||
--cpp-out "$temp_out/cpp" \
|
||||
--cpp-namespace "$cpp_namespace" \
|
||||
--ident-cpp-enum-type FooBar \
|
||||
--ident-cpp-method FooBar \
|
||||
\
|
||||
--jni-out "$temp_out/jni" \
|
||||
--ident-jni-class NativeFooBar \
|
||||
--ident-jni-file NativeFooBar \
|
||||
\
|
||||
--yaml-out $(dirname "$in_idl") \
|
||||
--yaml-out-file "$(basename "$in_idl" .djinni).yaml" \
|
||||
\
|
||||
--idl "$in_idl"
|
||||
}
|
||||
|
||||
djinni_build "$base_dir/mynteye_types.djinni"
|
||||
djinni_build "$base_dir/mynteye.djinni"
|
||||
|
||||
# copy
|
||||
|
||||
|
||||
Reference in New Issue
Block a user