-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Modify "Add Exif support/ THETA Z1 support"
- Loading branch information
Showing
7 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
130 changes: 130 additions & 0 deletions
130
library/src/main/java/com/theta360/pluginlibrary/exif/CameraAttitude.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 modified
BIN
+1.52 KB
(100%)
repository/com/theta360/pluginlibrary/2.1.0/pluginlibrary-2.1.0.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
repository/com/theta360/pluginlibrary/2.1.0/pluginlibrary-2.1.0.aar.md5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
d14e7ef3521038c25097b73538fd6c27 | ||
e04a5d0d7332141e80dea4e30db4c655 |
2 changes: 1 addition & 1 deletion
2
repository/com/theta360/pluginlibrary/2.1.0/pluginlibrary-2.1.0.aar.sha1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
515047ec7321672a6fed2274849597a854f690ac | ||
292c28a369cd017161d32ff7d5e0594d51ff1118 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4de49d494a7df0b08de088a1933581d7 | ||
7ac5748a87c3be6c70493f1c43c21590 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
c56c33133e2cce87dde55dc48964c7a34f58cc96 | ||
94ee540e6d94c4589eb6a35bebcf301cbddc5cba |