Google Tango Java SDK开发:Motion Tracking 运动追踪
Java API Motion Tracking Tutorial运动追踪教程
This page describes how the Java API handles motion tracking. 该页面描述了如何使用Java API处理运动追踪。
Lifecycle 生命周期
The normal motion tracking system lifecycle consists of three states: TangoPoseData.POSE_INITIALIZING
, TangoPoseData.POSE_VALID
, and TangoPoseData.POSE_INVALID
. In the POSE_INITIALIZING
state, the system is not yet ready and pose data is not available. In the POSE_VALID
state, the system is functioning normally. In the POSE_INVALID
state, the system believes its estimate was invalid and needs to be reinitialized. A fourth state, POSE_UNKNOWN
, is used for all other cases.
一般的运动追踪系统生命周期包括三个状态:TangoPoseData.POSE_INITIALIZING, TangoPoseData.POSE_VALID,和TangoPoseData.POSE_INVALID。在POSE_INITIALIZING状态时,系统还没有准备好,姿态数据不可用。在POSE_VALID状态时,系统运行正常。在POSE_INVALID状态时,系统认定它的估计是无效的需要重新初始化。第四种状态POSE_UNKNOWN表示其他状态。
Should the pose data become POSE_INVALID
, the motion tracking system can be reinitialized in two ways. If config_enable_auto_recovery
was set to true, the system will immediately enter the POSE_INITIALIZING
state. It will use the last valid pose as the starting point after recovery. IfTangoConfig.KEY_BOOLEAN_AUTORECOVERY
was set to false, the system will essentially pause and always return poses as POSE_INVALID
until Tango.resetMotionTracking()
is called. Unlike auto recovery, this will also reset the starting point after recovery back to the origin.
假如姿态数据变成POSE_INVALID,运动追踪系统可以以两种方式重新初始化。如果config_enable_auto_recovery设为真,系统将很快输入POSE_INITIALIZING状态。它将使用最后的有效姿态作为恢复后的初始点。如果TangoConfig.KEY_BOOLEAN_AUTORECOVERY设为否,系统将根本上中止,并总是返回POSE_INVALID直到调用Tango.resetMotionTracking()。这不同于自动恢复,它在恢复到原点后也会重设开始点。
The lifecycle state is recorded in the TangoPoseData object's statusCode
. 生命周期状态是记录在TangoPoseData对象的statusCode中。
For more information, although the page is based around the C API, please see our Device Pose concepts page. 对于更多信息,虽然该网页是基于C API的,也请看我们的设备姿态概念页。
Configuration配置信息
In order to use motion tracking, your TangoConfig
must have KEY_BOOLEAN_MOTIONTRACKING
set to true. If you are using the default TangoConfig
as your starting point, it is already set to true.
为了使用运动追踪,你的TangoConfig必须将KEY_BOOLEAN_MOTIONTRACKING设为真。如果你正在使用默认的TangoConfig作为你的起始点,那么已经设为真。
You also have the option to set KEY_BOOLEAN_AUTORECOVERY
. In the default TangoConfig
, this is set to true. See the Lifecycle section for the behavior of this parameter.
你还有个选项可以设置KEY_BOOLEAN_AUTORECOVERY。在默认的TangoConfig中,这项设为真。看LifeCycle节查看本参数的行为。
Getting pose data获取姿态数据
There are two coordinate frame pair options for basic motion tracking: device with respect to start of service, and device with respect to the previous device pose. With start of service, the device's pose is relative to the position where the motion tracking system initialized. You can receive pose data in both the callback and polling forms. With previous device pose, the device's pose is relative to its last position. Pose data is only available as a callback.
有两个用于基本运动追踪的坐标框架对的选项:相对于开始服务的设备位姿,以及相对于上一个设备位姿的设备位姿。如果是相对于开始服务,那么设备位姿是相对于运动追踪系统初始化时的位置。你可以在反馈和请求两种形式中接收位姿数据。如果是相对于上一个设备位姿,设备位姿是相对于上一个位置。位姿数据只有在反馈中才可用。
Callback-based基于反馈的
If you are using the callback-based approach, you must define the coordinate frame pairs you are interested in and construct your onPoseAvailable()
callback.
如果你正在使用基于反馈的方法,你必须定义你感兴趣的坐标框架对,然后创建你的onPoseAvailable()反馈。
You also have to implement onXyzIjAvailable and onTangoEvent, because the Tango.OnTangoUpdateListenerinterface requires an implementation for all three of those methods.
你还需要引用onXyzljAvailable和onTangoEvent,因为Tango.OnTangoUpdateListener接口需要以上三个方法的引用。
private void setTangoListeners() {
final ArrayList<TangoCoordinateFramePair> framePairs = new ArrayList<TangoCoordinateFramePair>();
framePairs.add(new TangoCoordinateFramePair(
TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE,
TangoPoseData.COORDINATE_FRAME_DEVICE));
// Listen for new Tango data
mTango.connectListener(framePairs, new OnTangoUpdateListener() {
@Override
public void onPoseAvailable(final TangoPoseData pose) {
// Process pose data from device with respect to start of service
}
@Override
public void onXyzIjAvailable(TangoXyzIjData arg0) {
// We need this callback even if we don't use it
}
@Override
public void onTangoEvent(final TangoEvent event) {
// This callback also has to be here
}
});
}
Polling-based基于请求的
In the polling-based approach, you must first specify the coordinate frame pair you are interested in. For simple motion tracking, this will always be TangoPoseData.COORDINATE_FRAME_DEVICE
with respect toTangoPoseData.COORDINATE_FRAME_START_OF_SERVICE
.
在基于请求的方法中,你必须先指定你感兴趣的坐标框架对。对于简单的运动追踪,这总会是参考TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE的TangoPoseData.COORDINATE_FRAME_DEVICE。
// Define what motion is requested.
TangoCoordinateFramePair frames_of_reference;
frames_of_reference.baseFrame = TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE;
frames_of_reference.targetFrame = TangoPoseData.COORDINATE_FRAME_DEVICE;
Then call `Tango.getPoseAtTime() as desired. In the example below, the timestamp is set to 0.0 to get the latest pose. If you specify a specific timestamp, the system will return an interpolated pose at that exact time. Timestamps are relative to the device boot.
然后调用Tango.getPoseAtTime()作为期望的。在下面的例子中,时间戳设为0.0用以得到最新的位姿。如果你指定一个特定的时间戳,系统将返回特定时间的内插位姿。时间戳是相对于设备启动时。
new Thread(new Runnable() {
final int pollingUpdatePeriodMilliseconds = 66;
@Override
public void run() {
while (true) {
try {
Thread.sleep(pollingUpdatePeriodMilliseconds);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
final TangoPoseData queryPoseStartDevice =
mTango.getPoseAtTime(0.0, frames_of_reference);
} catch (TangoErrorException e) {
e.printStackTrace();
}
}
}
}).start();
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code samples are licensed under the Apache 2.0 License. For details, see our Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Google Tango Java SDK开发:Motion Tracking 运动追踪的更多相关文章
- Google Tango Java SDK开发:Configure and Connect 配置和连接
Configure and Connect 配置和连接 Note: This section assumes you are familiar with the Android Activity Li ...
- Apache Beam入门及Java SDK开发初体验
1 什么是Apache Beam Apache Beam是一个开源的统一的大数据编程模型,它本身并不提供执行引擎,而是支持各种平台如GCP Dataflow.Spark.Flink等.通过Apache ...
- [No0000105]java sdk 开发环境变量powershell 自动配置脚本
# 设置Java SDK 环境变量 $softwares = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Unin ...
- Google Tango Java实例程序
Java API:https://developers.google.com/tango/apis/java/reference/ 1. java_augmented_reality_example ...
- Google Tango初学者教程
Getting Started with the Tango Java API In this tutorial, we'll go through setting up your build env ...
- Hello_Motion_Tracking 任务一:Project Tango采集运动追踪数据
我们来看一下中的几个基本的例子 (区域描述.深度感知.运动追踪.视频4个) 参考:Google Tango初学者教程 1. hello_motion_tracking package com.proj ...
- 分享 Java微信开发SDK
分享 Java微信开发SDK •发布于 4周前 •作者 朋也 •432 次浏览 •最后一次编辑是 2周前 •来自 分享 给大家分享两个java开发微信公众号的sdk jfinal-weixin ...
- 区块链:基于Hyperledger Fabric的 java 客户端开发(java sdk /java api server/java event server)
fabric针对java 开发的部分支持不是很友好.基于目前较为稳定的fabric 1.4版本,我们封装了一个java sdk,apiserver,eventServer 封装java sdk的主要目 ...
- 微博开发平台java SDK demo学习之friendships
本文解释了在java SDK的demo中与feiendships有关的功能 截图如下: 关注一个用户(需要知道该用户uid) 取消关注一个用户(用户uid) 获取用户粉丝列表(授权用户的screen_ ...
随机推荐
- Centos 6 安装 配置 oracle11g R2
1.安装centos6.3_64位: 下载地址:http://mirror.bit.edu.cn/centos/6.3/isos/x86_64/ CentOS-6.3-x86_64-bin-DVD1. ...
- sublime text 2 卸载与重装
很多同学使用 sublime text2 的时候,出现一些奇怪的bug,且重启无法修复. 于是,就会想到卸载 sublime text2 再重新安装. 然而,你会发现,重新安装后,这个bug任然存在, ...
- java 面向对象 — 类和对象
构造方法 1.构造器必须与类同名(如果一个源文件中有多个类,那么构造器必须与公共类同名) 2.每个类可以有一个以上的构造器 3.构造器可以有0个.1个或1个以上的参数 4.构造器没有返回值 5.构造器 ...
- 学习笔记之Android
Android 开发专区 - 开源中国社区 http://www.oschina.net/android 探索 Android Studio | Android Studio https://deve ...
- mysql-2 数据类型
mysql中定义数据字段的类型对数据库的优化是非常重要的. mysql数据类型大致分为三类:数值.日期/时间.字符串(字符)类型. 数值类型 MySQL支持所有标准SQL数值数据类型. 这些类型包括严 ...
- [置顶]
Ubuntu16.04+opencv3.3.0的安装配置说明
系统环境: Linux Ubuntu 16.04 [GCC 5.4.0 20160609] on linux2 之前的教程中我们已经安装了做机器学习需要使用的框架TensorFlow,笔者本科阶段 ...
- 【Codeforces】Educational Codeforces Round 46(Contest 1000)
题目 传送门:QWQ A:Codehorses T-shirts 题意: 给定一些字符串表示去年和今年的衣服型号大小( XL XXL M...... ),要求用最少的次数把去年的衣服大小改成今年需要的 ...
- VCF文件导入导出
参考资料 通讯录导入导出vcf格式文件方法可参考: https://qiaodahai.com/android-iphone-mobile-phones-contacts-import-and-exp ...
- selenium+python自动化83-pip安装selenium报Read time out HTTPSConnectionPool(host='pypi.python.org' port443)
遇到问题 1.有些小伙伴在用pip安装selenium时候报 Read time out HTTPSConnectionPool(host='pypi.python.org' port443) 2.估 ...
- 一些linux知识和http知识
1 yum安装比源码编译安装 有的模块不能自定义安装 只能安装默认的模块进行安装 2 关于php的fastcgi 如果使用fastcgi 那么需要启动服务 如果不使用fastcgi 那么不需要启 ...