簡體   English   中英

Project Tango原始數據(IMU和RGBD)

[英]Project Tango Raw Data (IMU and RGBD)

我是Android和Tango的初學者(我只是想說這是為了防止可能的錯誤),並且我正在使用Project Tango Tablet(Yellowstone)。 我想對此大滿貫,這就是為什么我要獲取原始數據。

目前,我知道如何獲取poseData和點雲。 我讀到不可能獲得IMU和RGBD。 但是用某些示例顯示RGB圖片而不是RGBD是足夠的,但是我不知道該怎么做。 我認為它可能會與“ onFrameAvailable(int i)”一起使用,但我真的不知道如何獲取RGB圖片。

對於IMU數據,我看到有一個帶有“ onTangoEvent(TangoEvent tangoEvent)”的EVENT_IMU。 但是當它應該是高頻事件時,它永遠不會發生/永遠不會被處理對嗎? 但是我處理了EVENT_FEATURE_TRACKING(= 5)和EVENT_FISHEYE_CAMERA(= 2),所以“ onTangoEvent(TangoEvent tangoEvent)”可以工作。 所以我的問題如下:

  1. 如何獲得RGB圖片? (在矩陣,緩沖區或其他任何形式中)
  2. 為什么從未處理EVENT_IMU?
  3. 有沒有辦法獲取IMU數據或等效數據?

謝謝你的回答

我忘了說了,但是我解決了我的問題。 Tango的API不允許獲取原始數據(IMU和RGBD)。 但是您可以通過TangoImageBuffer使用c API獲得RGB。 您將獲得MV21圖片。 您將能夠將每個像素轉換為“ RGB單個像素”,然后將其轉換為RGBA數據。

對於IMU,只需忘記Tango的API並使用android API。 您可以輕松獲取它,然后將其傳輸到服務器。 我的情況下,我是通過使用ros Publisher實現的。 多虧了這一點,我才能獲得大約500個姿勢/秒,35個點雲/秒和900個IMU /秒的速度。 如果您對使用ros感興趣,可以查看此ROS Rviz可視化Tango Pose數據

-----編輯--------在這里,我將刪除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;
        }
    }
}

也許為時已晚。 但是,您是否有可能給我您的代碼以從Project-Tango獲得IMU測量值和RGB視頻。 我正在處理這個問題。 Tks很多!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM