zoukankan      html  css  js  c++  java
  • Hello_Depth_Perception 任务二:Project Tango采集深度感知数据

     Java API Depth Perception Tutorial深度感知教程

    Configuration 配置信息

    In order to use depth perception, your TangoConfig must have KEY_BOOLEAN_DEPTH set to true. In the default TangoConfigKEY_BOOLEAN_DEPTH is set to false.

    为了使用深度感知,你的TangoConfig必须将KEY_BOOLEAN_DEPTH设为真。

     
    try {
        mConfig = new TangoConfig();
        mConfig = mTango.getConfig(TangoConfig.CONFIG_TYPE_CURRENT);
        mConfig.putBoolean(TangoConfig.KEY_BOOLEAN_DEPTH, true);
    } catch (TangoErrorException e) {
        // handle exception
    }

    Define the callback定义回调

    The caller is responsible for allocating memory, which will be released after the callback function has finished.

    调用方负责分配内存空间,该空间将在该回调函数结束之后释放。

     
    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 onXyzIjAvailable(TangoXyzIjData arg0) {
                byte[] buffer = new byte[xyzIj.xyzCount * 3 * 4]; //文件流输入缓冲区
                FileInputStream fileStream = new FileInputStream(
                         xyzIj.xyzParcelFileDescriptor.getFileDescriptor()); //xyzIj的定义在哪里?输入xyzIj的文件路径
                try {
                    fileStream.read(buffer,
                            xyzIj.xyzParcelFileDescriptorOffset, buffer.length);
                    fileStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                // Do not process the buffer inside the callback because不要处理该回调中的缓冲,因为
                // you will not receive any new data while it processes在处理中你接收不到任何新数据
            }

            @Override
            public void onPoseAvailable(final TangoPoseData pose) {
                // Process pose data from device with respect to start of service
            }

            @Override
            public void onTangoEvent(final TangoEvent event) {
                // This callback also has to be here
            }
        });
    }

    Define the onXYZijAvailable() callback. Do not do any expensive processing on the data within the callback; you will not receive new data until the callback returns.

    定义onXYZijAvailable()回调。不要在回调中做任何高消耗的数据处理。你只有在回调返回时才能接收新数据。

  • 相关阅读:
    数据结构之 移位操作
    大话设计模式之外观模式
    JSP的内置对象(application)
    从键盘输入一个整数(1~20) 则以该数字为矩阵的大小,把1,2,3…n*n 的数字按照顺时针螺旋的形式填入其中。
    linux线程应用
    【网络挖掘:成就与未来方向】之网络挖掘应用程序与相关概念
    Thinking in Java之匿名内部类
    [Go] map
    [跟着hsp步步学习系统]oracle培训学习集锦全360度扫描(2)
    HDU3791:二叉搜索树
  • 原文地址:https://www.cnblogs.com/2008nmj/p/7218743.html
Copyright © 2011-2022 走看看