Skip to content

Commit

Permalink
Merge pull request #7 from ricohapi/feature/#4
Browse files Browse the repository at this point in the history
Modify "Add Exif support/ THETA Z1 support"
  • Loading branch information
j-takashima authored Oct 28, 2019
2 parents 6468e68 + 82dc8e9 commit 24ead3c
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/**
* Copyright 2018 Ricoh Company, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package com.theta360.pluginlibrary.exif;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.support.annotation.NonNull;

/**
* CameraAttitude
*/
public class CameraAttitude implements SensorEventListener {
private final float[] mAccelerometer;
private final float[] mMagnetic;
private final float[] mGyroscope;
private SensorManager mSensorManager;
private boolean mAccuracy;

private float[] mAttitudeSnupshot;
private boolean mAccuracySnupshot;

public CameraAttitude(@NonNull Context context) {
mAccelerometer = new float[3];
mMagnetic = new float[3];
mGyroscope = new float[3];
mAccuracy = true;

mAttitudeSnupshot = new float[3];
mAccuracySnupshot = true;

mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
}

public void register() {
if (mSensorManager != null) {
mSensorManager.registerListener(this,
mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SensorManager.SENSOR_DELAY_GAME);
mSensorManager.registerListener(this,
mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
SensorManager.SENSOR_DELAY_FASTEST);
mSensorManager.registerListener(this,
mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE),
SensorManager.SENSOR_DELAY_FASTEST);
}
}

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

@Override
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
System.arraycopy(event.values, 0, mAccelerometer, 0, mAccelerometer.length);
break;
case Sensor.TYPE_MAGNETIC_FIELD:
System.arraycopy(event.values, 0, mMagnetic, 0, mMagnetic.length);
break;
case Sensor.TYPE_GYROSCOPE:
System.arraycopy(event.values, 0, mGyroscope, 0, mGyroscope.length);
break;
}
}

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
switch (sensor.getType()) {
case Sensor.TYPE_MAGNETIC_FIELD:
switch (accuracy) {
case SensorManager.SENSOR_STATUS_UNRELIABLE:
mAccuracy = false;
break;
case SensorManager.SENSOR_STATUS_ACCURACY_HIGH:
mAccuracy = true;
break;
default:
break;
}
default:
break;
}
}

public boolean getAccuracy() {
return mAccuracy;
}

public float[] getAttitudeRadian() {
float[] inR = new float[16];
float[] outR = new float[16];
float[] I = new float[16];
float[] attitude = new float[3];

SensorManager.getRotationMatrix(inR, I, mAccelerometer, mMagnetic);
SensorManager.remapCoordinateSystem(inR, SensorManager.AXIS_X, SensorManager.AXIS_Y, outR);
SensorManager.getOrientation(outR, attitude);

return attitude;
}

public void snapshot() {
mAccuracySnupshot = getAccuracy();
mAttitudeSnupshot = getAttitudeRadian();
}

public boolean getAccuracySnapshot() {
return mAccuracySnupshot;
}

public float[] getAttitudeRadianSnapshot() {
return mAttitudeSnupshot;
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d14e7ef3521038c25097b73538fd6c27
e04a5d0d7332141e80dea4e30db4c655
Original file line number Diff line number Diff line change
@@ -1 +1 @@
515047ec7321672a6fed2274849597a854f690ac
292c28a369cd017161d32ff7d5e0594d51ff1118
2 changes: 1 addition & 1 deletion repository/com/theta360/pluginlibrary/maven-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<version>2.0.0</version>
<version>2.1.0</version>
</versions>
<lastUpdated>20191028015910</lastUpdated>
<lastUpdated>20191028051259</lastUpdated>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4de49d494a7df0b08de088a1933581d7
7ac5748a87c3be6c70493f1c43c21590
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c56c33133e2cce87dde55dc48964c7a34f58cc96
94ee540e6d94c4589eb6a35bebcf301cbddc5cba

0 comments on commit 24ead3c

Please sign in to comment.