Project Tango原始数据(IMU和RGBD)

时间:2016-05-10 00:25:28

标签: android rgb google-project-tango raw-data tango

我是Android的初学者和Tango(我只是想说它是为了防止可能出现的错误)而且我正在使用Project Tango Tablet(黄石)。我想用它来抨击,这就是我想获取原始数据的原因。

目前我知道如何获得poseData和点云。我读到无法获得IMU和RGBD。但是,不是RGBD,而是通过一些样本显示的RGB图像可能是合适的,但我不知道得到它。我认为它可能适用于" onFrameAvailable(int i)"但我真的不知道如何获得RGB图片。

对于IMU数据,我看到EVENT_IMU有" onTangoEvent(TangoEvent tangoEvent)"。但它永远不会发生/从未被处理过它应该是一个高频事件吗?但是我处理EVENT_FEATURE_TRACKING(= 5)和EVENT_FISHEYE_CAMERA(= 2)所以" onTangoEvent(TangoEvent tangoEvent)"作品。 所以我的问题如下:

  1. 如何获取RGB图片? (在矩阵,缓冲或其他任何方面)
  2. 为什么永远不会处理EVENT_IMU?
  3. 有没有办法获取IMU数据或等效的东西?
  4. 感谢您的回答

2 个答案:

答案 0 :(得分:3)

我忘了说,但我解决了我的问题。 Tango的API不允许获取原始数据(IMU和RGBD)。但是你可以通过TangoImageBuffer获得带有c api的RGB。你会得到一张MV21照片。您将能够转换" RGB单像素中的每个像素"然后在RGBA数据中转换此像素。

对于IMU,只需忘记Tango的API并使用android API。您可以轻松地获取它,然后将其传输到服务器。我的情况是我通过使用ros发布者来做到这一点。多亏了这一点,我能够获得500个姿势/秒,35点云/秒和900 IMU /秒之类的东西。 如果您对使用ros感兴趣,可以查看ROS Rviz visualization of Tango Pose data

-----编辑-------- 这里是我的git中的代码(请参阅评论中的下一个问题),因为我将删除它:

import android.Manifest;
import android.app.Activity;
import android.content.Context;

import android.content.pm.PackageManager;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;

import android.os.Bundle;
import android.support.v4.app.ActivityCompat;

public class IMU implements SensorEventListener {
    private long timestampAccelerometerSensor, timestampLinearAccelerationSensor, timestampRotationSensor;
    private long timestampGravitySensor, timestampGyroscopeSensor, timestampMagneticFieldSensor;
    private String  tAccelerometerSensor, tLinearAccelerationSensor, tRotationSensor;
    private String tGravitySensor, tGyroscopeSensor, tMagneticFieldSensor, tGPS;

    private long countAccelerometerSensor, countLinearAccelerationSensor, countRotationSensor;
    private long countGravitySensor, countGyroscopeSensor, countMagneticFieldSensor;

    //for GPS
    private LocationManager locationManager;
    private LocationListener locationListener;
    private double longitude, latitude;

    //for IMU
    private SensorManager mSensorManager;
    private Sensor accelerometerSensor;
    private Sensor linearAccelerationSensor;
    private Sensor rotationSensor;
    private Sensor gravitySensor;
    private Sensor gyroscopeSensor;

    private Sensor magneticFieldSensor;

    float accelerationForce[] = new float[3];//Including gravity, Acceleration force along x,y,z axis in m/s²
    float linearAccelerationForce[] = new float[3];//Excluding gravity, Acceleration force along x,y,z axis in m/s²
    float gravity[] = new float[3];//Force of gravity along x,y,z axis in m/s²
    float gyroscope[] = new float[3];//Rate of rotation around x,y,z axis in rad/s
    float rotation[] = new float[4]; //Rotation vector component along the x,y,z axis and Scalar component of the rotation vector
    float magneticField[] = new float[3];//Geomagnetic field strength along x,y,z axis uT


public void create(){
        mSensorManager = (SensorManager) mainActivity.getSystemService(Context.SENSOR_SERVICE);

        locationManager = (LocationManager) mainActivity.getSystemService(Context.LOCATION_SERVICE);
        locationListener = new LocationListener() {
            @Override
            public void onLocationChanged(Location location) {
                //gpsView.setText("Longitude: " + location.getLongitude() + "\nLatitude: " + location.getLatitude());
                //Log.i("GPS","Longitude: " + location.getLongitude() + "\nLatitude: " + location.getLatitude());
                tGPS = TangoJNINative.getCurrentTimeMillisString();
                longitude = location.getLongitude();
                latitude = location.getLatitude();
            }

            @Override
            public void onStatusChanged(String provider, int status, Bundle extras) {

            }

            @Override
            public void onProviderEnabled(String provider) {
                //gpsStatusView.setText("GPS ---> On");
            }

            @Override
            public void onProviderDisabled(String provider) {
                //gpsStatusView.setText("GPS ---> Off");
            }
        };

        if (ActivityCompat.checkSelfPermission(mainActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mainActivity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

        String locationProvider = LocationManager.NETWORK_PROVIDER;
        Location firstLocation = locationManager.getLastKnownLocation(locationProvider);
        longitude = firstLocation.getLongitude();
        latitude = firstLocation.getLatitude();

        setSensors();
        setSensorsListeners();
    }

public void pause(){
        mSensorManager.unregisterListener(this);
    }

    public void resume(){
        setSensorsListeners();
    }

    private void setSensors(){
        accelerometerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        linearAccelerationSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION);
        rotationSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
        gravitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
        gyroscopeSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);

        magneticFieldSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    }

    private void setSensorsListeners(){
        mSensorManager.registerListener(this, accelerometerSensor , SensorManager.SENSOR_DELAY_NORMAL);
        mSensorManager.registerListener(this, linearAccelerationSensor , SensorManager.SENSOR_DELAY_NORMAL);
        mSensorManager.registerListener(this, rotationSensor , SensorManager.SENSOR_DELAY_NORMAL);
        mSensorManager.registerListener(this, gravitySensor , SensorManager.SENSOR_DELAY_NORMAL);
        mSensorManager.registerListener(this, gyroscopeSensor , SensorManager.SENSOR_DELAY_NORMAL);

        mSensorManager.registerListener(this, magneticFieldSensor , SensorManager.SENSOR_DELAY_NORMAL);
    }

    @Override
    public void onSensorChanged(SensorEvent event) {
        getIMU(event);
    }

    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {

    }

    private void getIMU(SensorEvent e){
        switch(e.sensor.getType()){
            case Sensor.TYPE_ACCELEROMETER:
                accelerationForce[0] = e.values[0];
                accelerationForce[1] = e.values[1];
                accelerationForce[2] = e.values[2];
                countAccelerometerSensor++;
                timestampAccelerometerSensor = e.timestamp;
                tAccelerometerSensor = TangoJNINative.getCurrentTimeMillisString();
                break;
            case Sensor.TYPE_LINEAR_ACCELERATION:
                linearAccelerationForce[0] = e.values[0];
                linearAccelerationForce[1] = e.values[1];
                linearAccelerationForce[2] = e.values[2];
                countLinearAccelerationSensor++;
                timestampLinearAccelerationSensor = e.timestamp;
                tLinearAccelerationSensor = TangoJNINative.getCurrentTimeMillisString();
                break;
            case Sensor.TYPE_ROTATION_VECTOR:
                rotation[0] = e.values[0];
                rotation[1] = e.values[1];
                rotation[2] = e.values[2];
                rotation[3] = e.values[3];
                countRotationSensor++;
                timestampRotationSensor = e.timestamp;
                tRotationSensor = TangoJNINative.getCurrentTimeMillisString();
                break;
            case Sensor.TYPE_GRAVITY:
                gravity[0] = e.values[0];
                gravity[1] = e.values[1];
                gravity[2] = e.values[2];
                countGravitySensor++;
                timestampGravitySensor = e.timestamp;
                tGravitySensor = TangoJNINative.getCurrentTimeMillisString();
                break;
            case Sensor.TYPE_GYROSCOPE:
                gyroscope[0] = e.values[0];
                gyroscope[1] = e.values[1];
                gyroscope[2] = e.values[2];
                countGyroscopeSensor++;
                timestampGyroscopeSensor= e.timestamp;
                tGyroscopeSensor = TangoJNINative.getCurrentTimeMillisString();
                break;
            case Sensor.TYPE_MAGNETIC_FIELD:
                magneticField[0] = e.values[0];
                magneticField[1] = e.values[1];
                magneticField[2] = e.values[2];
                countMagneticFieldSensor++;
                timestampMagneticFieldSensor = e.timestamp;
                tMagneticFieldSensor = TangoJNINative.getCurrentTimeMillisString();
                break;
        }
    }
}

答案 1 :(得分:0)

或许你来不及问你。但有没有机会你可以给我你的代码来从Project-Tango获得IMU测量和RGB视频。我现在正在处理这个问题。 Tks很多!