use of android.util.Rational in project platform_frameworks_base by android.
the class CameraMetadataTest method testReadWritePrimitiveArray.
@SmallTest
public void testReadWritePrimitiveArray() {
// int32 (n)
checkKeyGetAndSet("android.sensor.info.sensitivityRange", int[].class, new int[] { 0xC0FFEE, 0xDEADF00D });
// byte (n)
checkKeyGetAndSet("android.statistics.faceScores", byte[].class, new byte[] { 1, 2, 3, 4 });
// int64 (n)
checkKeyGetAndSet("android.scaler.availableProcessedMinDurations", long[].class, new long[] { 0xABCD12345678FFFFL, 0x1234ABCD5678FFFFL, 0xFFFF12345678ABCDL });
// float (n)
checkKeyGetAndSet("android.lens.info.availableApertures", float[].class, new float[] { Float.MAX_VALUE, Float.MIN_NORMAL, Float.MIN_VALUE });
// double (n) -- in particular double x 3
checkKeyGetAndSet("android.jpeg.gpsCoordinates", double[].class, new double[] { Double.MAX_VALUE, Double.MIN_NORMAL, Double.MIN_VALUE });
// rational (n) -- in particular rational x 9
checkKeyGetAndSet("android.sensor.calibrationTransform1", Rational[].class, new Rational[] { new Rational(1, 2), new Rational(3, 4), new Rational(5, 6), new Rational(7, 8), new Rational(9, 10), new Rational(10, 11), new Rational(12, 13), new Rational(14, 15), new Rational(15, 16) });
/**
* Weirder cases, that don't map 1:1 with the native types
*/
// bool (n) -- with TYPE_BYTE
checkKeyGetAndSet("android.control.aeLock", boolean[].class, new boolean[] { true, false, true });
// integer (n) -- with TYPE_BYTE
checkKeyGetAndSet("android.control.aeAvailableModes", int[].class, new int[] { 1, 2, 3, 4 });
}
use of android.util.Rational in project android_frameworks_base by DirtyUnicorns.
the class ColorSpaceTransform method equals.
/**
* Check if this {@link ColorSpaceTransform} is equal to another {@link ColorSpaceTransform}.
*
* <p>Two color space transforms are equal if and only if all of their elements are
* {@link Object#equals equal}.</p>
*
* @return {@code true} if the objects were equal, {@code false} otherwise
*/
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (obj instanceof ColorSpaceTransform) {
final ColorSpaceTransform other = (ColorSpaceTransform) obj;
for (int i = 0, j = 0; i < COUNT; ++i, j += RATIONAL_SIZE) {
int numerator = mElements[j + OFFSET_NUMERATOR];
int denominator = mElements[j + OFFSET_DENOMINATOR];
int numeratorOther = other.mElements[j + OFFSET_NUMERATOR];
int denominatorOther = other.mElements[j + OFFSET_DENOMINATOR];
Rational r = new Rational(numerator, denominator);
Rational rOther = new Rational(numeratorOther, denominatorOther);
if (!r.equals(rOther)) {
return false;
}
}
return true;
}
return false;
}
use of android.util.Rational in project android_frameworks_base by DirtyUnicorns.
the class StaticMetadata method getAeCompensationStepChecked.
/**
* Get value of key android.control.aeCompensationStep and do the sanity check.
*
* @return default value if the value is null.
*/
public Rational getAeCompensationStepChecked() {
Key<Rational> key = CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP;
Rational compensationStep = getValueFromKeyNonNull(key);
if (compensationStep == null) {
// Return default step.
return CONTROL_AE_COMPENSATION_STEP_DEFAULT;
}
// Legacy devices don't have a minimum step requirement
if (isHardwareLevelLimitedOrBetter()) {
float compensationStepF = (float) compensationStep.getNumerator() / compensationStep.getDenominator();
checkTrueForKey(key, " value must be no more than 1/2", compensationStepF <= 0.5f);
}
return compensationStep;
}
use of android.util.Rational in project android_frameworks_base by DirtyUnicorns.
the class StaticMetadata method getAeCompensationRangeChecked.
/**
* Get value of key android.control.aeCompensationRange and do the sanity check.
*
* @return default value if the value is null or malformed.
*/
public Range<Integer> getAeCompensationRangeChecked() {
Key<Range<Integer>> key = CameraCharacteristics.CONTROL_AE_COMPENSATION_RANGE;
Range<Integer> compensationRange = getValueFromKeyNonNull(key);
Rational compensationStep = getAeCompensationStepChecked();
float compensationStepF = compensationStep.floatValue();
final Range<Integer> DEFAULT_RANGE = Range.create((int) (CONTROL_AE_COMPENSATION_RANGE_DEFAULT_MIN / compensationStepF), (int) (CONTROL_AE_COMPENSATION_RANGE_DEFAULT_MAX / compensationStepF));
final Range<Integer> ZERO_RANGE = Range.create(0, 0);
if (compensationRange == null) {
return ZERO_RANGE;
}
// Legacy devices don't have a minimum range requirement
if (isHardwareLevelLimitedOrBetter() && !compensationRange.equals(ZERO_RANGE)) {
checkTrueForKey(key, " range value must be at least " + DEFAULT_RANGE + ", actual " + compensationRange + ", compensation step " + compensationStep, compensationRange.getLower() <= DEFAULT_RANGE.getLower() && compensationRange.getUpper() >= DEFAULT_RANGE.getUpper());
}
return compensationRange;
}
use of android.util.Rational in project android_frameworks_base by AOSPA.
the class Camera2StillCaptureTest method verifyRawCaptureResult.
/**
* Validate that raw {@link CaptureResult}.
*
* @param rawRequest a {@link CaptureRequest} use to capture a RAW16 image.
* @param rawResult the {@link CaptureResult} corresponding to the given request.
*/
private void verifyRawCaptureResult(CaptureRequest rawRequest, CaptureResult rawResult) {
assertNotNull(rawRequest);
assertNotNull(rawResult);
Rational[] empty = new Rational[] { Rational.ZERO, Rational.ZERO, Rational.ZERO };
Rational[] neutralColorPoint = mCollector.expectKeyValueNotNull("NeutralColorPoint", rawResult, CaptureResult.SENSOR_NEUTRAL_COLOR_POINT);
if (neutralColorPoint != null) {
mCollector.expectEquals("NeutralColorPoint length", empty.length, neutralColorPoint.length);
mCollector.expectNotEquals("NeutralColorPoint cannot be all zeroes, ", empty, neutralColorPoint);
mCollector.expectValuesGreaterOrEqual("NeutralColorPoint", neutralColorPoint, Rational.ZERO);
}
mCollector.expectKeyValueGreaterOrEqual(rawResult, CaptureResult.SENSOR_GREEN_SPLIT, 0.0f);
Pair<Double, Double>[] noiseProfile = mCollector.expectKeyValueNotNull("NoiseProfile", rawResult, CaptureResult.SENSOR_NOISE_PROFILE);
if (noiseProfile != null) {
mCollector.expectEquals("NoiseProfile length", noiseProfile.length, /*Num CFA channels*/
4);
for (Pair<Double, Double> p : noiseProfile) {
mCollector.expectTrue("NoiseProfile coefficients " + p + " must have: S > 0, O >= 0", p.first > 0 && p.second >= 0);
}
}
Integer hotPixelMode = mCollector.expectKeyValueNotNull("HotPixelMode", rawResult, CaptureResult.HOT_PIXEL_MODE);
Boolean hotPixelMapMode = mCollector.expectKeyValueNotNull("HotPixelMapMode", rawResult, CaptureResult.STATISTICS_HOT_PIXEL_MAP_MODE);
Point[] hotPixelMap = rawResult.get(CaptureResult.STATISTICS_HOT_PIXEL_MAP);
Size pixelArraySize = mStaticInfo.getPixelArraySizeChecked();
boolean[] availableHotPixelMapModes = mStaticInfo.getValueFromKeyNonNull(CameraCharacteristics.STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES);
if (hotPixelMode != null) {
Integer requestMode = mCollector.expectKeyValueNotNull(rawRequest, CaptureRequest.HOT_PIXEL_MODE);
if (requestMode != null) {
mCollector.expectKeyValueEquals(rawResult, CaptureResult.HOT_PIXEL_MODE, requestMode);
}
}
if (hotPixelMapMode != null) {
Boolean requestMapMode = mCollector.expectKeyValueNotNull(rawRequest, CaptureRequest.STATISTICS_HOT_PIXEL_MAP_MODE);
if (requestMapMode != null) {
mCollector.expectKeyValueEquals(rawResult, CaptureResult.STATISTICS_HOT_PIXEL_MAP_MODE, requestMapMode);
}
if (!hotPixelMapMode) {
mCollector.expectTrue("HotPixelMap must be empty", hotPixelMap == null || hotPixelMap.length == 0);
} else {
mCollector.expectTrue("HotPixelMap must not be empty", hotPixelMap != null);
mCollector.expectNotNull("AvailableHotPixelMapModes must not be null", availableHotPixelMapModes);
if (availableHotPixelMapModes != null) {
mCollector.expectContains("HotPixelMapMode", availableHotPixelMapModes, true);
}
int height = pixelArraySize.getHeight();
int width = pixelArraySize.getWidth();
for (Point p : hotPixelMap) {
mCollector.expectTrue("Hotpixel " + p + " must be in pixelArray " + pixelArraySize, p.x >= 0 && p.x < width && p.y >= 0 && p.y < height);
}
}
}
// TODO: profileHueSatMap, and profileToneCurve aren't supported yet.
}
Aggregations