Closed yangchengjian closed 6 years ago
Could you provide a snippet of your code around ArSession_create?
I got this error when the JavaVM was not attached to the current thread during certain AR calls, this fixed it for me
activity->vm->AttachCurrentThread(&(activity->env), NULL);
and then detaching afterwards with
activity->vm->DetachCurrentThread();
although it's not clear if or when the detach should be done.
extern crate android_injected_glue;
mod ffi_arcore {
include!(concat!(env!("OUT_DIR"), "/arcore_bindings.rs"));
}
use ffi_arcore::{ArCamera, ArConfig, ArFrame, ArSession, ArStatus};
use ffi_arcore::{ArCamera_getProjectionMatrix, ArFrame_acquireCamera, ArFrame_create, ArSession_create, ArConfig_create};
use android_injected_glue::{Event};
use android_injected_glue::{add_sender, get_app, write_log};
use android_injected_glue::ffi::{android_app, ANativeActivity};
fn main() {
use std::sync::mpsc::channel;
write_log("main() has been called");
let (sender, receiver) = channel::<Event>();
add_sender(sender);
let app: &mut android_app = get_app();
let activity: *const ANativeActivity = (*app).activity;
let env: *mut ::std::os::raw::c_void = unsafe { (*activity).env as *mut ::std::os::raw::c_void};
let ctx: *mut ::std::os::raw::c_void = unsafe { (*app).userData as *mut ::std::os::raw::c_void };
let mut out_session_pointer: *mut ArSession = ::std::ptr::null_mut();
let mut ar_status: ArStatus = unsafe {ArSession_create(env, ctx, &mut out_session_pointer)};
loop {
android_injected_glue::write_log(&format!("_______EVENT_________{:?}", receiver.recv()));
}
}
@inio
file arcore_bindings.rs generated by bindgen
/* automatically generated by rust-bindgen */
pub const _STDINT_H: ::std::os::raw::c_uint = 1;
pub const _FEATURES_H: ::std::os::raw::c_uint = 1;
pub const _DEFAULT_SOURCE: ::std::os::raw::c_uint = 1;
pub const __USE_ISOC11: ::std::os::raw::c_uint = 1;
pub const __USE_ISOC99: ::std::os::raw::c_uint = 1;
pub const __USE_ISOC95: ::std::os::raw::c_uint = 1;
pub const __USE_POSIX_IMPLICITLY: ::std::os::raw::c_uint = 1;
pub const _POSIX_SOURCE: ::std::os::raw::c_uint = 1;
pub const _POSIX_C_SOURCE: ::std::os::raw::c_uint = 200809;
pub const __USE_POSIX: ::std::os::raw::c_uint = 1;
pub const __USE_POSIX2: ::std::os::raw::c_uint = 1;
pub const __USE_POSIX199309: ::std::os::raw::c_uint = 1;
pub const __USE_POSIX199506: ::std::os::raw::c_uint = 1;
pub const __USE_XOPEN2K: ::std::os::raw::c_uint = 1;
pub const __USE_XOPEN2K8: ::std::os::raw::c_uint = 1;
pub const _ATFILE_SOURCE: ::std::os::raw::c_uint = 1;
pub const __USE_MISC: ::std::os::raw::c_uint = 1;
pub const __USE_ATFILE: ::std::os::raw::c_uint = 1;
pub const __USE_FORTIFY_LEVEL: ::std::os::raw::c_uint = 0;
pub const _STDC_PREDEF_H: ::std::os::raw::c_uint = 1;
pub const __STDC_IEC_559__: ::std::os::raw::c_uint = 1;
pub const __STDC_IEC_559_COMPLEX__: ::std::os::raw::c_uint = 1;
pub const __STDC_ISO_10646__: ::std::os::raw::c_uint = 201505;
pub const __STDC_NO_THREADS__: ::std::os::raw::c_uint = 1;
pub const __GNU_LIBRARY__: ::std::os::raw::c_uint = 6;
pub const __GLIBC__: ::std::os::raw::c_uint = 2;
pub const __GLIBC_MINOR__: ::std::os::raw::c_uint = 23;
pub const _SYS_CDEFS_H: ::std::os::raw::c_uint = 1;
pub const __WORDSIZE: ::std::os::raw::c_uint = 64;
pub const __WORDSIZE_TIME64_COMPAT32: ::std::os::raw::c_uint = 1;
pub const __SYSCALL_WORDSIZE: ::std::os::raw::c_uint = 64;
pub const _BITS_WCHAR_H: ::std::os::raw::c_uint = 1;
pub const INT8_MIN: ::std::os::raw::c_int = -128;
pub const INT16_MIN: ::std::os::raw::c_int = -32768;
pub const INT32_MIN: ::std::os::raw::c_int = -2147483648;
pub const INT8_MAX: ::std::os::raw::c_uint = 127;
pub const INT16_MAX: ::std::os::raw::c_uint = 32767;
pub const INT32_MAX: ::std::os::raw::c_uint = 2147483647;
pub const UINT8_MAX: ::std::os::raw::c_uint = 255;
pub const UINT16_MAX: ::std::os::raw::c_uint = 65535;
pub const UINT32_MAX: ::std::os::raw::c_uint = 4294967295;
pub const INT_LEAST8_MIN: ::std::os::raw::c_int = -128;
pub const INT_LEAST16_MIN: ::std::os::raw::c_int = -32768;
pub const INT_LEAST32_MIN: ::std::os::raw::c_int = -2147483648;
pub const INT_LEAST8_MAX: ::std::os::raw::c_uint = 127;
pub const INT_LEAST16_MAX: ::std::os::raw::c_uint = 32767;
pub const INT_LEAST32_MAX: ::std::os::raw::c_uint = 2147483647;
pub const UINT_LEAST8_MAX: ::std::os::raw::c_uint = 255;
pub const UINT_LEAST16_MAX: ::std::os::raw::c_uint = 65535;
pub const UINT_LEAST32_MAX: ::std::os::raw::c_uint = 4294967295;
pub const INT_FAST8_MIN: ::std::os::raw::c_int = -128;
pub const INT_FAST16_MIN: ::std::os::raw::c_longlong = -9223372036854775808;
pub const INT_FAST32_MIN: ::std::os::raw::c_longlong = -9223372036854775808;
pub const INT_FAST8_MAX: ::std::os::raw::c_uint = 127;
pub const INT_FAST16_MAX: ::std::os::raw::c_ulonglong = 9223372036854775807;
pub const INT_FAST32_MAX: ::std::os::raw::c_ulonglong = 9223372036854775807;
pub const UINT_FAST8_MAX: ::std::os::raw::c_uint = 255;
pub const UINT_FAST16_MAX: ::std::os::raw::c_int = -1;
pub const UINT_FAST32_MAX: ::std::os::raw::c_int = -1;
pub const INTPTR_MIN: ::std::os::raw::c_longlong = -9223372036854775808;
pub const INTPTR_MAX: ::std::os::raw::c_ulonglong = 9223372036854775807;
pub const UINTPTR_MAX: ::std::os::raw::c_int = -1;
pub const PTRDIFF_MIN: ::std::os::raw::c_longlong = -9223372036854775808;
pub const PTRDIFF_MAX: ::std::os::raw::c_ulonglong = 9223372036854775807;
pub const SIG_ATOMIC_MIN: ::std::os::raw::c_int = -2147483648;
pub const SIG_ATOMIC_MAX: ::std::os::raw::c_uint = 2147483647;
pub const SIZE_MAX: ::std::os::raw::c_int = -1;
pub const WINT_MIN: ::std::os::raw::c_uint = 0;
pub const WINT_MAX: ::std::os::raw::c_uint = 4294967295;
pub type wchar_t = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Debug, Copy)]
pub struct max_align_t {
pub __clang_max_align_nonce1: ::std::os::raw::c_longlong,
pub __bindgen_padding_0: u64,
pub __clang_max_align_nonce2: f64,
}
#[test]
fn bindgen_test_layout_max_align_t() {
assert_eq!(::std::mem::size_of::<max_align_t>() , 32usize , concat ! (
"Size of: " , stringify ! ( max_align_t ) ));
}
impl Clone for max_align_t {
fn clone(&self) -> Self { *self }
}
pub type int_least8_t = ::std::os::raw::c_schar;
pub type int_least16_t = ::std::os::raw::c_short;
pub type int_least32_t = ::std::os::raw::c_int;
pub type int_least64_t = ::std::os::raw::c_long;
pub type uint_least8_t = ::std::os::raw::c_uchar;
pub type uint_least16_t = ::std::os::raw::c_ushort;
pub type uint_least32_t = ::std::os::raw::c_uint;
pub type uint_least64_t = ::std::os::raw::c_ulong;
pub type int_fast8_t = ::std::os::raw::c_schar;
pub type int_fast16_t = ::std::os::raw::c_long;
pub type int_fast32_t = ::std::os::raw::c_long;
pub type int_fast64_t = ::std::os::raw::c_long;
pub type uint_fast8_t = ::std::os::raw::c_uchar;
pub type uint_fast16_t = ::std::os::raw::c_ulong;
pub type uint_fast32_t = ::std::os::raw::c_ulong;
pub type uint_fast64_t = ::std::os::raw::c_ulong;
pub type intmax_t = ::std::os::raw::c_long;
pub type uintmax_t = ::std::os::raw::c_ulong;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArConfig_ {
_unused: [u8; 0],
}
/// An opaque session configuration object (@ref ownership "value type").
///
/// Create with ArConfig_create()<br>
/// Release with ArConfig_destroy()
pub type ArConfig = ArConfig_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArSession_ {
_unused: [u8; 0],
}
/// The ArCore session (@ref ownership "value type").
///
/// Create with ArSession_create()<br>
/// Release with ArSession_destroy()
pub type ArSession = ArSession_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArPose_ {
_unused: [u8; 0],
}
/// A structured rigid transformation (@ref ownership "value type").
///
/// Allocate with ArPose_create()<br>
/// Release with ArPose_destroy()
pub type ArPose = ArPose_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArCamera_ {
_unused: [u8; 0],
}
/// The virtual and physical camera
/// (@ref ownership "reference type, long-lived").
///
/// Acquire with ArFrame_acquireCamera()<br>
/// Release with ArCamera_release()
pub type ArCamera = ArCamera_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArFrame_ {
_unused: [u8; 0],
}
/// The world state resulting from an update (@ref ownership "value type").
///
/// Allocate with ArFrame_create()<br>
/// Populate with ArSession_update()<br>
/// Release with ArFrame_destroy()
pub type ArFrame = ArFrame_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArLightEstimate_ {
_unused: [u8; 0],
}
/// An estimate of the real-world lighting (@ref ownership "value type").
///
/// Allocate with ArLightEstimate_create()<br>
/// Populate with ArFrame_getLightEstimate()<br>
/// Release with ArLightEstimate_destroy()
pub type ArLightEstimate = ArLightEstimate_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArPointCloud_ {
_unused: [u8; 0],
}
/// A cloud of tracked 3D visual feature points
/// (@ref ownership "reference type, large data").
///
/// Acquire with ArFrame_acquirePointCloud()<br>
/// Release with ArPointCloud_release()
pub type ArPointCloud = ArPointCloud_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArImageMetadata_ {
_unused: [u8; 0],
}
/// Camera capture metadata (@ref ownership "reference type, large data").
///
/// Acquire with ArFrame_acquireImageMetadata()<br>
/// Release with ArImageMetadata_release()
pub type ArImageMetadata = ArImageMetadata_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArTrackable_ {
_unused: [u8; 0],
}
/// Trackable base type (@ref ownership "reference type, long-lived").
pub type ArTrackable = ArTrackable_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArTrackableList_ {
_unused: [u8; 0],
}
/// A list of ArTrackables (@ref ownership "value type").
///
/// Allocate with ArTrackableList_create()<br>
/// Release with ArTrackableList_destroy()
pub type ArTrackableList = ArTrackableList_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArPlane_ {
_unused: [u8; 0],
}
/// A detected planar surface (@ref ownership "reference type, long-lived").
///
/// Trackable type: #AR_TRACKABLE_PLANE <br>
/// Release with: ArTrackable_release()
pub type ArPlane = ArPlane_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArPoint_ {
_unused: [u8; 0],
}
/// An arbitrary point in space (@ref ownership "reference type, long-lived").
///
/// Trackable type: #AR_TRACKABLE_POINT <br>
/// Release with: ArTrackable_release()
pub type ArPoint = ArPoint_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArAnchor_ {
_unused: [u8; 0],
}
/// A position in space attached to a trackable
/// (@ref ownership "reference type, long-lived").
///
/// Create with ArSession_acquireNewAnchor() or
/// ArHitResult_acquireNewAnchor()<br>
/// Release with ArAnchor_release()
pub type ArAnchor = ArAnchor_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArAnchorList_ {
_unused: [u8; 0],
}
/// A list of anchors (@ref ownership "value type").
///
/// Allocate with ArAnchorList_create()<br>
/// Release with ArAnchorList_destroy()
pub type ArAnchorList = ArAnchorList_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArHitResult_ {
_unused: [u8; 0],
}
/// A single trackable hit (@ref ownership "value type").
///
/// Allocate with ArHitResult_create()<br>
/// Populate with ArHitResultList_getItem()<br>
/// Release with ArHitResult_destroy()
pub type ArHitResult = ArHitResult_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ArHitResultList_ {
_unused: [u8; 0],
}
/// A list of hit test results (@ref ownership "value type").
///
/// Allocate with ArHitResultList_create()<br>
/// Release with ArHitResultList_destroy()<br>
pub type ArHitResultList = ArHitResultList_;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ACameraMetadata {
_unused: [u8; 0],
}
pub type ArTrackableType = i32;
pub const AR_TRACKABLE_BASE_TRACKABLE: _bindgen_ty_1 =
_bindgen_ty_1::AR_TRACKABLE_BASE_TRACKABLE;
pub const AR_TRACKABLE_PLANE: _bindgen_ty_1 =
_bindgen_ty_1::AR_TRACKABLE_PLANE;
pub const AR_TRACKABLE_POINT: _bindgen_ty_1 =
_bindgen_ty_1::AR_TRACKABLE_POINT;
pub const AR_TRACKABLE_NOT_VALID: _bindgen_ty_1 =
_bindgen_ty_1::AR_TRACKABLE_NOT_VALID;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_1 {
AR_TRACKABLE_BASE_TRACKABLE = 1095893248,
AR_TRACKABLE_PLANE = 1095893249,
AR_TRACKABLE_POINT = 1095893250,
AR_TRACKABLE_NOT_VALID = 0,
}
pub type ArStatus = i32;
pub const AR_SUCCESS: _bindgen_ty_2 = _bindgen_ty_2::AR_SUCCESS;
pub const AR_ERROR_INVALID_ARGUMENT: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_INVALID_ARGUMENT;
pub const AR_ERROR_FATAL: _bindgen_ty_2 = _bindgen_ty_2::AR_ERROR_FATAL;
pub const AR_ERROR_SESSION_PAUSED: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_SESSION_PAUSED;
pub const AR_ERROR_SESSION_NOT_PAUSED: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_SESSION_NOT_PAUSED;
pub const AR_ERROR_NOT_TRACKING: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_NOT_TRACKING;
pub const AR_ERROR_TEXTURE_NOT_SET: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_TEXTURE_NOT_SET;
pub const AR_ERROR_MISSING_GL_CONTEXT: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_MISSING_GL_CONTEXT;
pub const AR_ERROR_UNSUPPORTED_CONFIGURATION: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_UNSUPPORTED_CONFIGURATION;
pub const AR_ERROR_CAMERA_PERMISSION_NOT_GRANTED: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_CAMERA_PERMISSION_NOT_GRANTED;
pub const AR_ERROR_DEADLINE_EXCEEDED: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_DEADLINE_EXCEEDED;
pub const AR_ERROR_RESOURCE_EXHAUSTED: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_RESOURCE_EXHAUSTED;
pub const AR_ERROR_NOT_YET_AVAILABLE: _bindgen_ty_2 =
_bindgen_ty_2::AR_ERROR_NOT_YET_AVAILABLE;
pub const AR_UNAVAILABLE_ARCORE_NOT_INSTALLED: _bindgen_ty_2 =
_bindgen_ty_2::AR_UNAVAILABLE_ARCORE_NOT_INSTALLED;
pub const AR_UNAVAILABLE_DEVICE_NOT_COMPATIBLE: _bindgen_ty_2 =
_bindgen_ty_2::AR_UNAVAILABLE_DEVICE_NOT_COMPATIBLE;
pub const AR_UNAVAILABLE_ANDROID_VERSION_NOT_SUPPORTED: _bindgen_ty_2 =
_bindgen_ty_2::AR_UNAVAILABLE_ANDROID_VERSION_NOT_SUPPORTED;
pub const AR_UNAVAILABLE_APK_TOO_OLD: _bindgen_ty_2 =
_bindgen_ty_2::AR_UNAVAILABLE_APK_TOO_OLD;
pub const AR_UNAVAILABLE_SDK_TOO_OLD: _bindgen_ty_2 =
_bindgen_ty_2::AR_UNAVAILABLE_SDK_TOO_OLD;
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_2 {
AR_SUCCESS = 0,
AR_ERROR_INVALID_ARGUMENT = -1,
AR_ERROR_FATAL = -2,
AR_ERROR_SESSION_PAUSED = -3,
AR_ERROR_SESSION_NOT_PAUSED = -4,
AR_ERROR_NOT_TRACKING = -5,
AR_ERROR_TEXTURE_NOT_SET = -6,
AR_ERROR_MISSING_GL_CONTEXT = -7,
AR_ERROR_UNSUPPORTED_CONFIGURATION = -8,
AR_ERROR_CAMERA_PERMISSION_NOT_GRANTED = -9,
AR_ERROR_DEADLINE_EXCEEDED = -10,
AR_ERROR_RESOURCE_EXHAUSTED = -11,
AR_ERROR_NOT_YET_AVAILABLE = -12,
AR_UNAVAILABLE_ARCORE_NOT_INSTALLED = -100,
AR_UNAVAILABLE_DEVICE_NOT_COMPATIBLE = -101,
AR_UNAVAILABLE_ANDROID_VERSION_NOT_SUPPORTED = -102,
AR_UNAVAILABLE_APK_TOO_OLD = -103,
AR_UNAVAILABLE_SDK_TOO_OLD = -104,
}
pub type ArTrackingState = i32;
pub const AR_TRACKING_STATE_TRACKING: _bindgen_ty_3 =
_bindgen_ty_3::AR_TRACKING_STATE_TRACKING;
pub const AR_TRACKING_STATE_PAUSED: _bindgen_ty_3 =
_bindgen_ty_3::AR_TRACKING_STATE_PAUSED;
pub const AR_TRACKING_STATE_STOPPED: _bindgen_ty_3 =
_bindgen_ty_3::AR_TRACKING_STATE_STOPPED;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_3 {
AR_TRACKING_STATE_TRACKING = 0,
AR_TRACKING_STATE_PAUSED = 1,
AR_TRACKING_STATE_STOPPED = 2,
}
pub type ArLightEstimationMode = i32;
pub const AR_LIGHT_ESTIMATION_MODE_DISABLED: _bindgen_ty_4 =
_bindgen_ty_4::AR_LIGHT_ESTIMATION_MODE_DISABLED;
pub const AR_LIGHT_ESTIMATION_MODE_AMBIENT_INTENSITY: _bindgen_ty_4 =
_bindgen_ty_4::AR_LIGHT_ESTIMATION_MODE_AMBIENT_INTENSITY;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_4 {
AR_LIGHT_ESTIMATION_MODE_DISABLED = 0,
AR_LIGHT_ESTIMATION_MODE_AMBIENT_INTENSITY = 1,
}
pub type ArPlaneFindingMode = i32;
pub const AR_PLANE_FINDING_MODE_DISABLED: _bindgen_ty_5 =
_bindgen_ty_5::AR_PLANE_FINDING_MODE_DISABLED;
pub const AR_PLANE_FINDING_MODE_HORIZONTAL: _bindgen_ty_5 =
_bindgen_ty_5::AR_PLANE_FINDING_MODE_HORIZONTAL;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_5 {
AR_PLANE_FINDING_MODE_DISABLED = 0,
AR_PLANE_FINDING_MODE_HORIZONTAL = 1,
}
pub type ArUpdateMode = i32;
pub const AR_UPDATE_MODE_BLOCKING: _bindgen_ty_6 =
_bindgen_ty_6::AR_UPDATE_MODE_BLOCKING;
pub const AR_UPDATE_MODE_LATEST_CAMERA_IMAGE: _bindgen_ty_6 =
_bindgen_ty_6::AR_UPDATE_MODE_LATEST_CAMERA_IMAGE;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_6 {
AR_UPDATE_MODE_BLOCKING = 0,
AR_UPDATE_MODE_LATEST_CAMERA_IMAGE = 1,
}
pub type ArPlaneType = i32;
pub const AR_PLANE_HORIZONTAL_UPWARD_FACING: _bindgen_ty_7 =
_bindgen_ty_7::AR_PLANE_HORIZONTAL_UPWARD_FACING;
pub const AR_PLANE_HORIZONTAL_DOWNWARD_FACING: _bindgen_ty_7 =
_bindgen_ty_7::AR_PLANE_HORIZONTAL_DOWNWARD_FACING;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_7 {
AR_PLANE_HORIZONTAL_UPWARD_FACING = 0,
AR_PLANE_HORIZONTAL_DOWNWARD_FACING = 1,
}
pub type ArLightEstimateState = i32;
pub const AR_LIGHT_ESTIMATE_STATE_NOT_VALID: _bindgen_ty_8 =
_bindgen_ty_8::AR_LIGHT_ESTIMATE_STATE_NOT_VALID;
pub const AR_LIGHT_ESTIMATE_STATE_VALID: _bindgen_ty_8 =
_bindgen_ty_8::AR_LIGHT_ESTIMATE_STATE_VALID;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_8 {
AR_LIGHT_ESTIMATE_STATE_NOT_VALID = 0,
AR_LIGHT_ESTIMATE_STATE_VALID = 1,
}
extern "C" {
/// Attempts to create a new ARCore session.
///
/// This is the entry point of ARCore. This function MUST be the first ARCore
/// call made by an application.
///
/// @param[in] env The application's @c JNIEnv object
/// @param[in] application_context A @c jobject referencing the application's
/// Android @c Context
/// @param[out] out_session_pointer A pointer to an @c ArSession* to receive
/// the address of the newly allocated session.
/// @return #AR_SUCCESS or any of:
/// - #AR_UNAVAILABLE_ARCORE_NOT_INSTALLED
/// - #AR_UNAVAILABLE_DEVICE_NOT_COMPATIBLE
/// - #AR_UNAVAILABLE_ANDROID_VERSION_NOT_SUPPORTED
/// - #AR_UNAVAILABLE_APK_TOO_OLD
/// - #AR_UNAVAILABLE_SDK_TOO_OLD
pub fn ArSession_create(env: *mut ::std::os::raw::c_void,
application_context: *mut ::std::os::raw::c_void,
out_session_pointer: *mut *mut ArSession)
-> ArStatus;
}
extern "C" {
/// Creates a new configuration object and initializes it to a sensible default
/// configuration. Plane detection and lighting estimation are enabled, and
/// blocking update is selected. This configuration is guaranteed to be
/// supported on all devices that support ARCore.
pub fn ArConfig_create(session: *const ArSession,
out_config: *mut *mut ArConfig);
}
extern "C" {
/// Releases memory used by the provided configuration object.
pub fn ArConfig_destroy(config: *mut ArConfig);
}
extern "C" {
/// Stores the currently configured lighting estimation mode into
/// @c *light_estimation_mode.
pub fn ArConfig_getLightEstimationMode(session: *const ArSession,
config: *const ArConfig,
light_estimation_mode:
*mut ArLightEstimationMode);
}
extern "C" {
/// Sets the lighting estimation mode that should be used. See
/// ::ArLightEstimationMode for available options.
pub fn ArConfig_setLightEstimationMode(session: *const ArSession,
config: *mut ArConfig,
light_estimation_mode:
ArLightEstimationMode);
}
extern "C" {
/// Stores the currently configured plane finding mode into
/// @c *plane_finding_mode.
pub fn ArConfig_getPlaneFindingMode(session: *const ArSession,
config: *const ArConfig,
plane_finding_mode:
*mut ArPlaneFindingMode);
}
extern "C" {
/// Sets the plane finding mode that should be used. See
/// ::ArPlaneFindingMode for available options.
pub fn ArConfig_setPlaneFindingMode(session: *const ArSession,
config: *mut ArConfig,
plane_finding_mode:
ArPlaneFindingMode);
}
extern "C" {
/// Stores the currently configured behavior of @ref ArSession_update() into
/// @c *update_mode.
pub fn ArConfig_getUpdateMode(session: *const ArSession,
config: *const ArConfig,
update_mode: *mut ArUpdateMode);
}
extern "C" {
/// Sets the behavior of @ref ArSession_update(). See
/// ::ArUpdateMode for available options.
pub fn ArConfig_setUpdateMode(session: *const ArSession,
config: *mut ArConfig,
update_mode: ArUpdateMode);
}
extern "C" {
/// Releases resources used by an ARCore session.
pub fn ArSession_destroy(session: *mut ArSession);
}
extern "C" {
/// Checks if the provided configuration is usable on the this device. If this
/// method returns #AR_ERROR_UNSUPPORTED_CONFIGURATION, calls to
/// ArSession_configure(Config) with this configuration will fail.
///
/// @param[in] session The ARCore session
/// @param[in] config The configuration to test
/// @return #AR_SUCCESS indicating the configuration is supported, or
/// #AR_ERROR_UNSUPPORTED_CONFIGURATION otherwise.
pub fn ArSession_checkSupported(session: *const ArSession,
config: *const ArConfig) -> ArStatus;
}
extern "C" {
/// Configures the session with the given config. The session must be paused.
///
/// @return #AR_SUCCESS or any of:
/// - #AR_ERROR_FATAL
/// - #AR_ERROR_UNSUPPORTED_CONFIGURATION
/// - #AR_ERROR_SESSION_NOT_PAUSED
pub fn ArSession_configure(session: *mut ArSession,
config: *const ArConfig) -> ArStatus;
}
extern "C" {
/// Starts or resumes the ARCore Session.
///
/// Typically this should be called from <a
/// href="https://developer.android.com/reference/android/app/Activity.html#onResume()"
/// ><tt>Activity.onResume()</tt></a>.
///
/// @returns #AR_SUCCESS or any of:
/// - #AR_ERROR_FATAL
/// - #AR_ERROR_CAMERA_PERMISSION_NOT_GRANTED
pub fn ArSession_resume(session: *mut ArSession) -> ArStatus;
}
extern "C" {
/// Pause the current session. This method will stop the camera feed and release
/// resources. The session can be restarted again by calling ArSession_resume().
///
/// Typically this should be called from <a
/// href="https://developer.android.com/reference/android/app/Activity.html#onPause()"
/// ><tt>Activity.onPause()</tt></a>.
///
/// @returns #AR_SUCCESS or any of:
/// - #AR_ERROR_FATAL
pub fn ArSession_pause(session: *mut ArSession) -> ArStatus;
}
extern "C" {
/// Sets the OpenGL texture name (id) that will allow GPU access to the camera
/// image. The provided ID should have been created with @c glGenTextures(). The
/// resulting texture must be bound to the @c GL_TEXTURE_EXTERNAL_OES target for
/// use. Shaders accessing this texture must use a @c samplerExternalOES
/// sampler. See sample code for an example.
pub fn ArSession_setCameraTextureName(session: *mut ArSession,
texture_id: u32);
}
extern "C" {
/// Sets the aspect ratio, coordinate scaling, and display rotation. This data
/// is used by UV conversion, projection matrix generation, and hit test logic.
///
/// Note: this function doesn't fail. If given invalid input, it logs a error
/// and doesn't apply the changes.
///
/// @param[in] session The ARCore session
/// @param[in] rotation Display rotation specified by @c android.view.Surface
/// constants: @c ROTATION_0, @c ROTATION_90, @c ROTATION_180 and
/// @c ROTATION_270
/// @param[in] width Width of the view, in pixels
/// @param[in] height Height of the view, in pixels
pub fn ArSession_setDisplayGeometry(session: *mut ArSession,
rotation: ::std::os::raw::c_int,
width: ::std::os::raw::c_int,
height: ::std::os::raw::c_int);
}
extern "C" {
/// Updates the state of the ARCore system. This includes: receiving a new
/// camera frame, updating the location of the device, updating the location of
/// tracking anchors, updating detected planes, etc.
///
/// This call may cause off-screen OpenGL activity. Because of this, to avoid
/// unnecessary frame buffer flushes and reloads, this call should not be made
/// in the middle of rendering an frame or offscreen buffer.
///
/// This call may update the pose of all created Anchors and detected Planes.
/// The set of updated objects is accessible through
/// ArFrame_getUpdatedTrackables().
///
/// This call may block until a new camera frame is available. See
/// ::ArUpdateMode for details.
///
/// @param[in] session The ARCore session
/// @param[inout] out_frame The Frame object to populate with the updated world
/// state. This frame must have been previously created using
/// ArFrame_create(). The same ArFrame instance may be used when calling
/// this repeatedly.
///
/// @return #AR_SUCCESS or any of:
/// - #AR_ERROR_FATAL
/// - #AR_ERROR_SESSION_PAUSED
/// - #AR_ERROR_TEXTURE_NOT_SET
/// - #AR_ERROR_MISSING_GL_CONTEXT
pub fn ArSession_update(session: *mut ArSession, out_frame: *mut ArFrame)
-> ArStatus;
}
extern "C" {
/// Defines a tracked location in the physical world.
///
/// @return #AR_SUCCESS or any of:
/// - #AR_ERROR_NOT_TRACKING
/// - #AR_ERROR_SESSION_PAUSED
/// - #AR_ERROR_RESOURCE_EXHAUSTED
pub fn ArSession_acquireNewAnchor(session: *mut ArSession,
pose: *const ArPose,
out_anchor: *mut *mut ArAnchor)
-> ArStatus;
}
extern "C" {
/// Returns all known anchors, including those not currently tracked. Anchors
/// forgotten by ARCore due to a call to ArAnchor_detach() or entering the
/// #AR_TRACKING_STATE_STOPPED state will not be included.
///
/// @param[in] session The ARCore session
/// @param[inout] out_anchor_list The list to fill. This list must have already
/// been allocated with ArAnchorList_create(). If previously used, the list
/// will first be cleared.
pub fn ArSession_getAllAnchors(session: *const ArSession,
out_anchor_list: *mut ArAnchorList);
}
extern "C" {
/// Returns the list of all known @ref trackable "trackables". This includes
/// ::ArPlane objects if plane detection is enabled, as well as ::ArPoint
/// objects created as a side effect of calls to ArSession_acquireNewAnchor() or
/// ArFrame_hitTest().
///
/// @param[in] session The ARCore session
/// @param[in] filter_type The type(s) of trackables to return. See
/// ::ArTrackableType for legal values.
/// @param[inout] out_trackable_list The list to fill. This list must have
/// already been allocated with ArTrackableList_create(). If previously
/// used, the list will first be cleared.
pub fn ArSession_getAllTrackables(session: *const ArSession,
filter_type: ArTrackableType,
out_trackable_list:
*mut ArTrackableList);
}
extern "C" {
/// Allocates and initializes a new pose object. @c pose_raw points to an array
/// of 7 floats, describing the rotation (quaternion) and translation of the
/// pose in the same order as the first 7 elements of the Android
/// @c Sensor.TYPE_POSE_6DOF values documented on <a
/// href="https://developer.android.com/reference/android/hardware/SensorEvent.html#values"
/// >@c SensorEvent.values() </a>
///
/// The order of the values is: qx, qy, qz, qw, tx, ty, tz.
///
/// If @c pose_raw is null, initializes with the identity pose.
pub fn ArPose_create(session: *const ArSession, pose_raw: *const f32,
out_pose: *mut *mut ArPose);
}
extern "C" {
/// Releases memory used by a pose object.
pub fn ArPose_destroy(pose: *mut ArPose);
}
extern "C" {
/// Extracts the quaternion rotation and translation from a pose object.
/// @param[in] session The ARCore session
/// @param[in] pose The pose to extract
/// @param[out] out_pose_raw Pointer to an array of 7 floats, to be filled with
/// the quaternion rotation and translation as described in ArPose_create().
pub fn ArPose_getPoseRaw(session: *const ArSession, pose: *const ArPose,
out_pose_raw: *mut f32);
}
extern "C" {
/// Converts a pose into a 4x4 transformation matrix.
/// @param[in] session The ARCore session
/// @param[in] pose The pose to convert
/// @param[out] out_matrix_col_major_4x4 Pointer to an array of 16 floats, to be
/// filled with a column-major homogenous transformation matrix, as used by
/// OpenGL.
pub fn ArPose_getMatrix(session: *const ArSession, pose: *const ArPose,
out_matrix_col_major_4x4: *mut f32);
}
extern "C" {
/// Sets @c out_pose to the pose of the user's device in the world coordinate
/// space at the time of capture of the current camera texture. The position and
/// orientation of the pose follow the device's physical camera (they are not
/// affected by display orientation) and uses OpenGL camera conventions (+X
/// right, +Y up, -Z in the direction the camera is looking).
///
/// Note: This pose is only useful when ArCamera_getTrackingState() returns
/// #AR_TRACKING_STATE_TRACKING and otherwise should not be used.
///
/// @param[in] session The ARCore session
/// @param[in] camera The session's camera (retrieved from any frame).
/// @param[inout] out_pose An already-allocated ArPose object into which the
/// pose will be stored.
pub fn ArCamera_getPose(session: *const ArSession,
camera: *const ArCamera, out_pose: *mut ArPose);
}
extern "C" {
/// Sets @c out_pose to the pose of the user's device in the world coordinate
/// space at the time of capture of the current camera texture. The position of
/// the pose is located at the device's camera, while the orientation
/// approximately matches the orientation of the display (considering display
/// rotation), using OpenGL camera conventions (+X right, +Y up, -Z in the
/// direction the camera is looking).
///
/// Note: This pose is only useful when ArCamera_getTrackingState() returns
/// #AR_TRACKING_STATE_TRACKING and otherwise should not be used.
///
/// See also: ArCamera_getViewMatrix()
///
/// @param[in] session The ARCore session
/// @param[in] camera The session's camera (retrieved from any frame).
/// @param[inout] out_pose An already-allocated ArPose object into which the
/// pose will be stored.
pub fn ArCamera_getDisplayOrientedPose(session: *const ArSession,
camera: *const ArCamera,
out_pose: *mut ArPose);
}
extern "C" {
/// Returns the view matrix for the camera for this frame. This matrix performs
/// the inverse transfrom as the pose provided by
/// ArCamera_getDisplayOrientedPose().
///
/// @param[in] session The ARCore session
/// @param[in] camera The session's camera.
/// @param[inout] out_col_major_4x4 Pointer to an array of 16 floats, to be
/// filled with a column-major homogenous transformation matrix, as used by
/// OpenGL.
pub fn ArCamera_getViewMatrix(session: *const ArSession,
camera: *const ArCamera,
out_col_major_4x4: *mut f32);
}
extern "C" {
/// Gets the current state of the pose of this camera. If this state is anything
/// other than #AR_TRACKING_STATE_TRACKING the Camera's pose should not be
/// considered useful.
pub fn ArCamera_getTrackingState(session: *const ArSession,
camera: *const ArCamera,
out_tracking_state:
*mut ArTrackingState);
}
extern "C" {
/// Computes a projection matrix for rendering virtual content on top of the
/// camera image. Note that the projection matrix reflects the current display
/// geometry and display rotation.
///
/// @param[in] session The ARCore session
/// @param[in] camera The session's camera.
/// @param[in] near Specifies the near clip plane, in meters
/// @param[in] far Specifies the far clip plane, in meters
/// @param[inout] dest_col_major_4x4 Pointer to an array of 16 floats, to
/// be filled with a column-major homogenous transformation matrix, as used
/// by OpenGL.
pub fn ArCamera_getProjectionMatrix(session: *const ArSession,
camera: *const ArCamera, near: f32,
far: f32,
dest_col_major_4x4: *mut f32);
}
extern "C" {
/// Releases a reference to the camera. This must match a call to
/// ArFrame_acquireCamera().
///
/// This method may safely be called with @c nullptr - it will do nothing.
pub fn ArCamera_release(camera: *mut ArCamera);
}
extern "C" {
/// Allocates a new ArFrame object, storing the pointer into @c *out_frame.
///
/// Note: the same ArFrame can be used repeatedly when calling ArSession_update.
pub fn ArFrame_create(session: *const ArSession,
out_frame: *mut *mut ArFrame);
}
extern "C" {
/// Releases an ArFrame and any references it holds.
pub fn ArFrame_destroy(frame: *mut ArFrame);
}
extern "C" {
/// Checks if the display rotation or viewport geometry changed since the
/// previous call to ArSession_update(). The application should re-query
/// ArCamera_getProjectionMatrix() and ArFrame_transformDisplayUvCoords()
/// whenever this emits non-zero.
pub fn ArFrame_getDisplayGeometryChanged(session: *const ArSession,
frame: *const ArFrame,
out_geometry_changed: *mut i32);
}
extern "C" {
/// Returns the timestamp in nanoseconds when this image was captured. This can
/// be used to detect dropped frames or measure the camera frame rate. The time
/// base of this value is specifically <b>not</b> defined, but it is likely
/// similar to <tt>clock_gettime(CLOCK_BOOTTIME)</tt>.
pub fn ArFrame_getTimestamp(session: *const ArSession,
frame: *const ArFrame,
out_timestamp_ns: *mut i64);
}
extern "C" {
/// Transform the given texture coordinates to correctly show the background
/// image. This will account for the display rotation, and any additional
/// required adjustment. For performance, this function should be called only if
/// ArFrame_hasDisplayGeometryChanged() emits true.
///
/// @param[in] session The ARCore session
/// @param[in] frame The current frame.
/// @param[in] num_elements The number of floats to transform. Must be
/// a multiple of 2. @c uvs_in and @c uvs_out must point to arrays of at
/// least this many floats.
/// @param[in] uvs_in Input UV coordinates in normalized screen space.
/// @param[inout] uvs_out Output UV coordinates in texture coordinates.
pub fn ArFrame_transformDisplayUvCoords(session: *const ArSession,
frame: *const ArFrame,
num_elements: i32,
uvs_in: *const f32,
uvs_out: *mut f32);
}
extern "C" {
/// Performs a ray cast from the user's device in the direction of the given
/// location in the camera view. Intersections with detected scene geometry are
/// returned, sorted by distance from the device; the nearest intersection is
/// returned first.
///
/// Note: Significant geometric leeway is given when returning hit results. For
/// example, a plane hit may be generated if the ray came close, but did not
/// actually hit within the plane extents or plane bounds
/// (ArPlane_isPoseInExtents() and ArPlane_isPoseInPolygon() can be used to
/// determine these cases). A point (point cloud) hit is generated when a point
/// is roughly within one finger-width of the provided screen coordinates.
///
/// The resulting list is ordered by distance, with the nearest hit first
///
/// Note: If not tracking, the hit_result_list will be empty. <br>
/// Note: If called on an old frame (not the latest produced by
/// ArSession_update() the hit_result_list will be empty).
///
/// @param[in] session The ARCore session.
/// @param[in] frame The current frame.
/// @param[in] pixel_x Logical X position within the view, as from an
/// Android UI event.
/// @param[in] pixel_y Logical X position within the view.
/// @param[inout] hit_result_list The list to fill. This list must have been
/// previously allocated using ArHitResultList_create(). If the list has
/// been previously used, it will first be cleared.
pub fn ArFrame_hitTest(session: *const ArSession, frame: *const ArFrame,
pixel_x: f32, pixel_y: f32,
hit_result_list: *mut ArHitResultList);
}
extern "C" {
/// Gets the current ambient light estimate, if light estimation was enabled.
///
/// @param[in] session The ARCore session.
/// @param[in] frame The current frame.
/// @param[inout] out_light_estimate The light estimate to fill. This object
/// must have been previously created with ArLightEstimate_create().
pub fn ArFrame_getLightEstimate(session: *const ArSession,
frame: *const ArFrame,
out_light_estimate: *mut ArLightEstimate);
}
extern "C" {
/// Acquires the current set of estimated 3d points attached to real-world
/// geometry. A matching call to PointCloud_release() must be made when the
/// application is done accessing the point cloud.
///
/// Note: This information is for visualization and debugging purposes only. Its
/// characteristics and format are subject to change in subsequent versions of
/// the API.
///
/// @param[in] session The ARCore session.
/// @param[in] frame The current frame.
/// @param[out] out_point_cloud Pointer to an @c ArPointCloud* receive the
/// address of the point cloud.
/// @return #AR_SUCCESS or any of:
/// - #AR_ERROR_DEADLINE_EXCEEDED if @c frame is not the latest frame from
/// by ArSession_update().
/// - #AR_ERROR_RESOURCE_EXHAUSTED if too many point clouds are currently held.
pub fn ArFrame_acquirePointCloud(session: *const ArSession,
frame: *const ArFrame,
out_point_cloud: *mut *mut ArPointCloud)
-> ArStatus;
}
extern "C" {
/// Returns the camera object for the session. Note that this Camera instance is
/// long-lived so the same instance is returned regardless of the frame object
/// this method was called on.
pub fn ArFrame_acquireCamera(session: *const ArSession,
frame: *const ArFrame,
out_camera: *mut *mut ArCamera);
}
extern "C" {
/// Gets the camera metadata for the current camera image.
///
/// @return #AR_SUCCESS or any of:
/// - #AR_ERROR_DEADLINE_EXCEEDED if @c frame is not the latest frame from
/// by ArSession_update().
/// - #AR_ERROR_RESOURCE_EXHAUSTED if too many metadata objects are currently
/// held.
pub fn ArFrame_acquireImageMetadata(session: *const ArSession,
frame: *const ArFrame,
out_metadata:
*mut *mut ArImageMetadata)
-> ArStatus;
}
extern "C" {
/// Gets the set of anchors that were changed by the ArSession_update() that
/// produced this Frame.
///
/// @param[in] session The ARCore session
/// @param[in] frame The current frame.
/// @param[inout] out_anchor_list The list to fill. This list must have
/// already been allocated with ArAnchorList_create(). If previously
/// used, the list will first be cleared.
pub fn ArFrame_getUpdatedAnchors(session: *const ArSession,
frame: *const ArFrame,
out_anchor_list: *mut ArAnchorList);
}
extern "C" {
/// Gets the set of trackables of a particular type that were changed by the
/// ArSession_update() call that produced this Frame.
///
/// @param[in] session The ARCore session
/// @param[in] frame The current frame.
/// @param[in] filter_type The type(s) of trackables to return. See
/// ::ArTrackableType for legal values.
/// @param[inout] out_trackable_list The list to fill. This list must have
/// already been allocated with ArTrackableList_create(). If previously
/// used, the list will first be cleared.
pub fn ArFrame_getUpdatedTrackables(session: *const ArSession,
frame: *const ArFrame,
filter_type: ArTrackableType,
out_trackable_list:
*mut ArTrackableList);
}
extern "C" {
/// Retrieves the number of points in the point cloud.
///
pub fn ArPointCloud_getNumberOfPoints(session: *const ArSession,
point_cloud: *const ArPointCloud,
out_number_of_points: *mut i32);
}
extern "C" {
/// Retrieves a pointer to the point cloud data.
///
/// Each point is represented by four consecutive values in the array; first the
/// X, Y, Z position coordinates, followed by a confidence value. This is the
/// same format as described in <a
/// href="https://developer.android.com/reference/android/graphics/ImageFormat.html#DEPTH_POINT_CLOUD"
/// >DEPTH_POINT_CLOUD</a>.
///
/// The pointer returned by this function is valid until ArPointCloud_release()
/// is called. The application must copy the data if they wish to retain it for
/// longer. The points are in world coordinates consistent with the frame it was
/// obtained from. If the number of points is zero, then the value of
/// @c *out_point_cloud_data should is undefined.
pub fn ArPointCloud_getData(session: *const ArSession,
point_cloud: *const ArPointCloud,
out_point_cloud_data: *mut *const f32);
}
extern "C" {
/// Returns the timestamp in nanoseconds when this point cloud was observed.
/// This timestamp uses the same time base as ArFrame_getTimestamp().
pub fn ArPointCloud_getTimestamp(session: *const ArSession,
point_cloud: *const ArPointCloud,
out_timestamp_ns: *mut i64);
}
extern "C" {
/// Releases a reference to the point cloud. This must match a call to
/// ArFrame_acquirePointCloud().
///
/// This method may safely be called with @c nullptr - it will do nothing.
pub fn ArPointCloud_release(point_cloud: *mut ArPointCloud);
}
extern "C" {
/// Retrieves the capture metadata for the current camera image.
///
/// @c ACameraMetadata is a struct in Android NDK. Include NdkCameraMetadata.h
/// to use this type.
///
/// Note: that the ACameraMetadata returned from this function will be invalid
/// after its ArImageMetadata object is released.
pub fn ArImageMetadata_getNdkCameraMetadata(session: *const ArSession,
image_metadata:
*const ArImageMetadata,
out_ndk_metadata:
*mut *const ACameraMetadata);
}
extern "C" {
/// Releases a reference to the metadata. This must match a call to
/// ArFrame_acquireImageMetadata().
///
/// This method may safely be called with @c nullptr - it will do nothing.
pub fn ArImageMetadata_release(metadata: *mut ArImageMetadata);
}
extern "C" {
/// Allocates a light estimate object.
pub fn ArLightEstimate_create(session: *const ArSession,
out_light_estimate:
*mut *mut ArLightEstimate);
}
extern "C" {
/// Releases the provided light estimate object.
pub fn ArLightEstimate_destroy(light_estimate: *mut ArLightEstimate);
}
extern "C" {
/// Retrieves the validity state of a light estimate. If the resulting value of
/// @c *out_light_estimate_state is not #AR_LIGHT_ESTIMATE_STATE_VALID, the
/// estimate should not be used for rendering.
pub fn ArLightEstimate_getState(session: *const ArSession,
light_estimate: *const ArLightEstimate,
out_light_estimate_state:
*mut ArLightEstimateState);
}
extern "C" {
/// Retrieves the pixel intensity of the current camera view. Values are in the
/// range (0.0, 1.0), with zero being black and one being white.
pub fn ArLightEstimate_getPixelIntensity(session: *const ArSession,
light_estimate:
*const ArLightEstimate,
out_pixel_intensity: *mut f32);
}
extern "C" {
/// Creates an anchor list object.
pub fn ArAnchorList_create(session: *const ArSession,
out_anchor_list: *mut *mut ArAnchorList);
}
extern "C" {
/// Releases the memory used by an anchor list object, along with all the anchor
/// references it holds.
pub fn ArAnchorList_destroy(anchor_list: *mut ArAnchorList);
}
extern "C" {
/// Retrieves the number of anchors in this list.
pub fn ArAnchorList_getSize(session: *const ArSession,
anchor_list: *const ArAnchorList,
out_size: *mut i32);
}
extern "C" {
/// Acquires a reference to an indexed entry in the list. This call must
/// eventually be matched with a call to ArAnchor_release().
pub fn ArAnchorList_acquireItem(session: *const ArSession,
anchor_list: *const ArAnchorList,
index: i32,
out_anchor: *mut *mut ArAnchor);
}
extern "C" {
/// Retrieves the pose of the anchor in the world coordinate space. This pose
/// produced by this call may change each time ArSession_update() is called.
/// This pose should only be used for rendering if ArAnchor_getTrackingState()
/// returns #AR_TRACKING_STATE_TRACKING.
///
/// @param[in] session The ARCore session.
/// @param[in] anchor The anchor to retrieve the pose of.
/// @param[inout] out_pose An already-allocated ArPose object into which the
/// pose will be stored.
pub fn ArAnchor_getPose(session: *const ArSession,
anchor: *const ArAnchor, out_pose: *mut ArPose);
}
extern "C" {
/// Retrieves the current state of the pose of this anchor.
pub fn ArAnchor_getTrackingState(session: *const ArSession,
anchor: *const ArAnchor,
out_tracking_state:
*mut ArTrackingState);
}
extern "C" {
/// Tells ARCore to stop tracking and forget this anchor. This call does not
/// release the reference to the anchor - that must be done separately using
/// ArAnchor_release().
pub fn ArAnchor_detach(session: *mut ArSession, anchor: *mut ArAnchor);
}
extern "C" {
/// Releases a reference to an anchor. This does not mean that the anchor will
/// stop tracking, as it will be obtainable from e.g. ArSession_getAllAnchors()
/// if any other references exist.
///
/// This method may safely be called with @c nullptr - it will do nothing.
pub fn ArAnchor_release(anchor: *mut ArAnchor);
}
extern "C" {
/// Creates a trackable list object.
pub fn ArTrackableList_create(session: *const ArSession,
out_trackable_list:
*mut *mut ArTrackableList);
}
extern "C" {
/// Releases the memory used by a trackable list object, along with all the
/// anchor references it holds.
pub fn ArTrackableList_destroy(trackable_list: *mut ArTrackableList);
}
extern "C" {
/// Retrieves the number of trackables in this list.
pub fn ArTrackableList_getSize(session: *const ArSession,
trackable_list: *const ArTrackableList,
out_size: *mut i32);
}
extern "C" {
/// Acquires a reference to an indexed entry in the list. This call must
/// eventually be matched with a call to ArTrackable_release().
pub fn ArTrackableList_acquireItem(session: *const ArSession,
trackable_list: *const ArTrackableList,
index: i32,
out_trackable: *mut *mut ArTrackable);
}
extern "C" {
/// Releases a reference to a trackable. This does not mean that the trackable
/// will necessarily stop tracking. The same trackable may still be included in
/// from other calls, for example ArSession_getAllTrackables().
///
/// This method may safely be called with @c nullptr - it will do nothing.
pub fn ArTrackable_release(trackable: *mut ArTrackable);
}
extern "C" {
/// Retrieves the type of the trackable. See ::ArTrackableType for valid types.
pub fn ArTrackable_getType(session: *const ArSession,
trackable: *const ArTrackable,
out_trackable_type: *mut ArTrackableType);
}
extern "C" {
/// Retrieves the current state of ARCore's knowledge of the pose of this
/// trackable.
pub fn ArTrackable_getTrackingState(session: *const ArSession,
trackable: *const ArTrackable,
out_tracking_state:
*mut ArTrackingState);
}
extern "C" {
/// Creates aa Anchor at the given pose in the world coordinate space, attached
/// to this Trackable, and acquires a reference to it. The type of Trackable
/// will determine the semantics of attachment and how the Anchor's pose will be
/// updated to maintain this relationship. Note that the relative offset between
/// the pose of multiple Anchors attached to a Trackable may adjust slightly
/// over time as ARCore updates its model of the world.
///
/// @return #AR_SUCCESS or any of:
/// - #AR_ERROR_NOT_TRACKING if the trackable's tracking state was not
/// #AR_TRACKING_STATE_TRACKING
/// - #AR_ERROR_SESSION_PAUSED if the session was paused
/// - #AR_ERROR_RESOURCE_EXHAUSTED if too many anchors exist
pub fn ArTrackable_acquireNewAnchor(session: *mut ArSession,
trackable: *mut ArTrackable,
pose: *mut ArPose,
out_anchor: *mut *mut ArAnchor)
-> ArStatus;
}
extern "C" {
/// Gets the set of anchors attached to this trackable.
///
/// @param[in] session The ARCore session
/// @param[in] trackable The trackable to query the anchors of.
/// @param[inout] out_anchor_list The list to fill. This list must have
/// already been allocated with ArAnchorList_create(). If previously
/// used, the list will first be cleared.
pub fn ArTrackable_getAnchors(session: *const ArSession,
trackable: *const ArTrackable,
out_anchor_list: *mut ArAnchorList);
}
extern "C" {
/// Acquires a reference to the plane subsuming this plane.
///
/// Two or more planes may be automatically merged into a single parent plane,
/// resulting in this method acquiring the parent plane when called with each
/// child plane. A subsumed plane becomes identical to the parent plane, and
/// will continue behaving as if it were independently tracked, for example
/// being included in the output of ArFrame_getUpdatedTrackables().
///
/// In cases where a subsuming plane is itself subsumed, this function
/// will always return the topmost non-subsumed plane.
///
/// Note: this function will set @c *out_subsumed_by to NULL if the plane is not
/// subsumed.
pub fn ArPlane_acquireSubsumedBy(session: *const ArSession,
plane: *const ArPlane,
out_subsumed_by: *mut *mut ArPlane);
}
extern "C" {
/// Retrieves the type (orientation) of the plane. See ::ArPlaneType.
pub fn ArPlane_getType(session: *const ArSession, plane: *const ArPlane,
out_plane_type: *mut ArPlaneType);
}
extern "C" {
/// Returns the pose of the center of the detected plane. The pose's transformed
/// +Y axis will be point normal out of the plane, with the +X and +Z axes
/// orienting the extents of the bounding rectangle.
///
/// @param[in] session The ARCore session.
/// @param[in] plane The plane for which to retrieve center pose.
/// @param[inout] out_pose An already-allocated ArPose object into which the
/// pose will be stored.
pub fn ArPlane_getCenterPose(session: *const ArSession,
plane: *const ArPlane,
out_pose: *mut ArPose);
}
extern "C" {
/// Retrieves the length of this plane's bounding rectangle measured along the
/// local X-axis of the coordinate space defined by the output of
/// ArPlane_getCenterPose().
pub fn ArPlane_getExtentX(session: *const ArSession,
plane: *const ArPlane, out_extent_x: *mut f32);
}
extern "C" {
/// Retrieves the length of this plane's bounding rectangle measured along the
/// local Z-axis of the coordinate space defined by the output of
/// ArPlane_getCenterPose().
pub fn ArPlane_getExtentZ(session: *const ArSession,
plane: *const ArPlane, out_extent_z: *mut f32);
}
extern "C" {
/// Retrieves the number of elements (not vertices) in the boundary polygon.
/// The number of vertices is 1/2 this size.
pub fn ArPlane_getPolygonSize(session: *const ArSession,
plane: *const ArPlane,
out_polygon_size: *mut i32);
}
extern "C" {
/// Returns the 2D vertices of a convex polygon approximating the detected
/// plane, in the form <tt>[x1, z1, x2, z2, ...]</tt>. These X-Z values are in
/// the plane's local x-z plane (y=0) and must be transformed by the pose
/// (ArPlane_getCenterPose()) to get the boundary in world coordinates.
///
/// @param[in] session The ARCore session.
/// @param[in] plane The plane to retrieve the polygon from.
/// @param[inout] out_polygon_xz A pointer to an array of floats. The length of
/// this array must be at least that reported by ArPlane_getPolygonSize().
pub fn ArPlane_getPolygon(session: *const ArSession,
plane: *const ArPlane,
out_polygon_xz: *mut f32);
}
extern "C" {
/// Sets @c *out_pose_in_extents to non-zero if the given pose (usually obtained
/// from a HitResult) is in the plane's rectangular extents.
pub fn ArPlane_isPoseInExtents(session: *const ArSession,
plane: *const ArPlane, pose: *const ArPose,
out_pose_in_extents: *mut i32);
}
extern "C" {
/// Sets @c *out_pose_in_extents to non-zero if the given pose (usually obtained
/// from a HitResult) is in the plane's polygon.
pub fn ArPlane_isPoseInPolygon(session: *const ArSession,
plane: *const ArPlane, pose: *const ArPose,
out_pose_in_polygon: *mut i32);
}
extern "C" {
/// Returns the pose of the point. For @c Point objects created by
/// ArFrame_hitTest(), the orientation will follow the behavior described in
/// ArHitResult_getPose().
///
/// @param[in] session The ARCore session.
/// @param[in] point The point to retrieve the pose of.
/// @param[inout] out_pose An already-allocated ArPose object into which the
/// pose will be stored.
pub fn ArPoint_getPose(session: *const ArSession, point: *const ArPoint,
out_pose: *mut ArPose);
}
extern "C" {
/// Creates a hit result list object.
pub fn ArHitResultList_create(session: *const ArSession,
out_hit_result_list:
*mut *mut ArHitResultList);
}
extern "C" {
/// Releases the memory used by a hit result list object, along with all the
/// trackable references it holds.
pub fn ArHitResultList_destroy(hit_result_list: *mut ArHitResultList);
}
extern "C" {
/// Retrieves the number of hit results in this list.
pub fn ArHitResultList_getSize(session: *const ArSession,
hit_result_list: *const ArHitResultList,
out_size: *mut i32);
}
extern "C" {
/// Copies an indexed entry in the list. This acquires a reference to any
/// trackable referenced by the item, and releases any reference currently held
/// by the provided result object.
///
/// @param[in] session The ARCore session.
/// @param[in] hit_result_list The list from which to copy an item.
/// @param[in] index Index of the entry to copy.
/// @param[inout] out_hit_result An already-allocated ArHitResult object into
/// which the result will be copied.
pub fn ArHitResultList_getItem(session: *const ArSession,
hit_result_list: *const ArHitResultList,
index: i32,
out_hit_result: *mut ArHitResult);
}
extern "C" {
/// Allocates an empty hit result object.
pub fn ArHitResult_create(session: *const ArSession,
out_hit_result: *mut *mut ArHitResult);
}
extern "C" {
/// Releases the memory used by a hit result object, along with any
/// trackable reference it holds.
pub fn ArHitResult_destroy(hit_result: *mut ArHitResult);
}
extern "C" {
/// Returns the distance from the camera to the hit location, in meters.
pub fn ArHitResult_getDistance(session: *const ArSession,
hit_result: *const ArHitResult,
out_distance: *mut f32);
}
extern "C" {
/// Returns the pose of the intersection between a ray and detected real-world
/// geometry. The position is the location in space where the ray intersected
/// the geometry. The orientation is a best effort to face the user's device,
/// and its exact definition differs depending on the Trackable that was hit.
///
/// ::ArPlane : X+ is perpendicular to the cast ray and parallel to the plane,
/// Y+ points along the plane normal (up, for #AR_PLANE_HORIZONTAL_UPWARD_FACING
/// planes), and Z+ is parallel to the plane, pointing roughly toward the
/// user's device.
///
/// ::ArPoint : X+ is perpendicular to the cast ray and points right from the
/// perspective of the user's device, Y+ points up, and Z+ points roughly toward
/// the user's device.
///
/// If you wish to retain the location of this pose beyond the duration of a
/// single frame, create an anchor using ArHitResult_createAnchor() to save the
/// pose in a physically consistent way.
///
/// @param[in] session The ARCore session.
/// @param[in] hit_result The hit result to retrieve the pose of.
/// @param[inout] out_pose An already-allocated ArPose object into which the
/// pose will be stored.
pub fn ArHitResult_getHitPose(session: *const ArSession,
hit_result: *const ArHitResult,
out_pose: *mut ArPose);
}
extern "C" {
/// Acquires reference to the hit trackable. This call must be paired with a
/// call to ArTrackable_release().
pub fn ArHitResult_acquireTrackable(session: *const ArSession,
hit_result: *const ArHitResult,
out_trackable: *mut *mut ArTrackable);
}
extern "C" {
/// Creates a new anchor at the hit location. See ArHitResult_getHitPose() for
/// details. This is equivalent to creating an anchor on the hit trackable at
/// the hit pose.
///
/// @return #AR_SUCCESS or any of:
/// - #AR_ERROR_NOT_TRACKING
/// - #AR_ERROR_SESSION_PAUSED
/// - #AR_ERROR_RESOURCE_EXHAUSTED
/// - #AR_ERROR_DEADLINE_EXCEEDED - hit result must be used before the next call
/// to update().
pub fn ArHitResult_acquireNewAnchor(session: *mut ArSession,
hit_result: *mut ArHitResult,
out_anchor: *mut *mut ArAnchor)
-> ArStatus;
}
Did you see @PaulSJ 's comment about running on the JNI thread? If this code is running on a different thread, you'll probably need to mess with the JNI context as they suggested.
Closing for inactivity