parent
337df9f540
commit
03f8358d67
@ -1,32 +0,0 @@ |
|||||||
package com.otaliastudios.cameraview; |
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.TargetApi; |
|
||||||
import android.hardware.Camera; |
|
||||||
import android.hardware.camera2.CameraCharacteristics; |
|
||||||
import android.support.test.filters.SmallTest; |
|
||||||
import android.support.test.runner.AndroidJUnit4; |
|
||||||
import android.util.SizeF; |
|
||||||
|
|
||||||
import org.junit.Test; |
|
||||||
import org.junit.runner.RunWith; |
|
||||||
import org.mockito.Mockito; |
|
||||||
|
|
||||||
import static org.mockito.Mockito.*; |
|
||||||
import static org.junit.Assert.*; |
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class) |
|
||||||
@SmallTest |
|
||||||
public class ExtraProperties1Test extends BaseTest { |
|
||||||
|
|
||||||
@Test |
|
||||||
public void testConstructor1() { |
|
||||||
Camera.Parameters params = mock(Camera.Parameters.class); |
|
||||||
when(params.getVerticalViewAngle()).thenReturn(10f); |
|
||||||
when(params.getHorizontalViewAngle()).thenReturn(5f); |
|
||||||
ExtraProperties e = new ExtraProperties(params); |
|
||||||
assertEquals(e.getVerticalViewingAngle(), 10f, 0f); |
|
||||||
assertEquals(e.getHorizontalViewingAngle(), 5f, 0f); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,39 +0,0 @@ |
|||||||
package com.otaliastudios.cameraview; |
|
||||||
|
|
||||||
|
|
||||||
import android.annotation.TargetApi; |
|
||||||
import android.hardware.Camera; |
|
||||||
import android.hardware.camera2.CameraCharacteristics; |
|
||||||
import android.util.Log; |
|
||||||
import android.util.SizeF; |
|
||||||
|
|
||||||
/** |
|
||||||
* Simple pojo containing various camera properties. |
|
||||||
*/ |
|
||||||
@SuppressWarnings("deprecation") |
|
||||||
public class ExtraProperties { |
|
||||||
|
|
||||||
private float verticalViewingAngle; |
|
||||||
private float horizontalViewingAngle; |
|
||||||
|
|
||||||
ExtraProperties(Camera.Parameters params) { |
|
||||||
verticalViewingAngle = params.getVerticalViewAngle(); |
|
||||||
horizontalViewingAngle = params.getHorizontalViewAngle(); |
|
||||||
} |
|
||||||
|
|
||||||
@TargetApi(21) |
|
||||||
ExtraProperties(CameraCharacteristics chars) { |
|
||||||
float[] maxFocus = chars.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS); |
|
||||||
SizeF size = chars.get(CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE); |
|
||||||
verticalViewingAngle = (float) Math.toDegrees(2 * Math.atan(size.getWidth() / (maxFocus[0] * 2))); |
|
||||||
horizontalViewingAngle = (float) Math.toDegrees(2 * Math.atan(size.getHeight() / (maxFocus[0] * 2))); |
|
||||||
} |
|
||||||
|
|
||||||
public float getHorizontalViewingAngle() { |
|
||||||
return horizontalViewingAngle; |
|
||||||
} |
|
||||||
|
|
||||||
public float getVerticalViewingAngle() { |
|
||||||
return verticalViewingAngle; |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue