use of android.hardware.camera2.CaptureResult in project android_frameworks_base by ResurrectionRemix.
the class CameraMetadata method getKeysStatic.
/**
* Return a list of all the Key<?> that are declared as a field inside of the class
* {@code type}.
*
* <p>
* Optionally, if {@code instance} is not null, then filter out any keys with null values.
* </p>
*
* <p>
* Optionally, if {@code filterTags} is not {@code null}, then filter out any keys
* whose native {@code tag} is not in {@code filterTags}. The {@code filterTags} array will be
* sorted as a side effect.
* </p>
*/
/*package*/
@SuppressWarnings("unchecked")
static <TKey> ArrayList<TKey> getKeysStatic(Class<?> type, Class<TKey> keyClass, CameraMetadata<TKey> instance, int[] filterTags) {
if (DEBUG)
Log.v(TAG, "getKeysStatic for " + type);
// TotalCaptureResult does not have any of the keys on it, use CaptureResult instead
if (type.equals(TotalCaptureResult.class)) {
type = CaptureResult.class;
}
if (filterTags != null) {
Arrays.sort(filterTags);
}
ArrayList<TKey> keyList = new ArrayList<TKey>();
Field[] fields = type.getDeclaredFields();
for (Field field : fields) {
// Filter for Keys that are public
if (field.getType().isAssignableFrom(keyClass) && (field.getModifiers() & Modifier.PUBLIC) != 0) {
TKey key;
try {
key = (TKey) field.get(instance);
} catch (IllegalAccessException e) {
throw new AssertionError("Can't get IllegalAccessException", e);
} catch (IllegalArgumentException e) {
throw new AssertionError("Can't get IllegalArgumentException", e);
}
if (instance == null || instance.getProtected(key) != null) {
if (shouldKeyBeAdded(key, field, filterTags)) {
keyList.add(key);
if (DEBUG) {
Log.v(TAG, "getKeysStatic - key was added - " + key);
}
} else if (DEBUG) {
Log.v(TAG, "getKeysStatic - key was filtered - " + key);
}
}
}
}
ArrayList<TKey> vendorKeys = CameraMetadataNative.getAllVendorKeys(keyClass);
if (vendorKeys != null) {
for (TKey k : vendorKeys) {
String keyName;
if (k instanceof CaptureRequest.Key<?>) {
keyName = ((CaptureRequest.Key<?>) k).getName();
} else if (k instanceof CaptureResult.Key<?>) {
keyName = ((CaptureResult.Key<?>) k).getName();
} else if (k instanceof CameraCharacteristics.Key<?>) {
keyName = ((CameraCharacteristics.Key<?>) k).getName();
} else {
continue;
}
if (filterTags == null || Arrays.binarySearch(filterTags, CameraMetadataNative.getTag(keyName)) >= 0) {
keyList.add(k);
}
}
}
return keyList;
}
use of android.hardware.camera2.CaptureResult in project android_frameworks_base by ResurrectionRemix.
the class CameraMetadataTest method testCaptureResult.
@SmallTest
public void testCaptureResult() {
mMetadata.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH);
if (VERBOSE)
mMetadata.dumpToLog();
CaptureResult captureResult = new CaptureResult(mMetadata, /*sequenceId*/
0);
List<CaptureResult.Key<?>> allKeys = captureResult.getKeys();
if (VERBOSE)
Log.v(TAG, "testCaptureResult: key list size " + allKeys);
for (CaptureResult.Key<?> key : captureResult.getKeys()) {
if (VERBOSE) {
Log.v(TAG, "testCaptureResult: key " + key + " value" + captureResult.get(key));
}
}
// FIXME: android.statistics.faces counts as a key
assertTrue(allKeys.size() >= 1);
assertTrue(allKeys.contains(CaptureResult.CONTROL_AE_MODE));
assertEquals(CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH, (int) captureResult.get(CaptureResult.CONTROL_AE_MODE));
}
use of android.hardware.camera2.CaptureResult in project android_frameworks_base by DirtyUnicorns.
the class Camera2CaptureRequestTest method autoAeMultipleCapturesThenTestLock.
/**
* Issue multiple auto AE captures, then lock AE, validate the AE lock vs.
* the first capture result after the AE lock. The right AE lock behavior is:
* When it is locked, it locks to the current exposure value, and all subsequent
* request with lock ON will have the same exposure value locked.
*/
private void autoAeMultipleCapturesThenTestLock(CaptureRequest.Builder requestBuilder, int aeMode, int numCapturesDuringLock) throws Exception {
if (numCapturesDuringLock < 1) {
throw new IllegalArgumentException("numCapturesBeforeLock must be no less than 1");
}
if (VERBOSE) {
Log.v(TAG, "Camera " + mCamera.getId() + ": Testing auto AE mode and lock for mode " + aeMode + " with " + numCapturesDuringLock + " captures before lock");
}
final int NUM_CAPTURES_BEFORE_LOCK = 2;
SimpleCaptureCallback listener = new SimpleCaptureCallback();
CaptureResult[] resultsDuringLock = new CaptureResult[numCapturesDuringLock];
boolean canSetAeLock = mStaticInfo.isAeLockSupported();
// Reset the AE lock to OFF, since we are reusing this builder many times
if (canSetAeLock) {
requestBuilder.set(CaptureRequest.CONTROL_AE_LOCK, false);
}
// Just send several captures with auto AE, lock off.
CaptureRequest request = requestBuilder.build();
for (int i = 0; i < NUM_CAPTURES_BEFORE_LOCK; i++) {
mSession.capture(request, listener, mHandler);
}
waitForNumResults(listener, NUM_CAPTURES_BEFORE_LOCK);
if (!canSetAeLock) {
// Without AE lock, the remaining tests items won't work
return;
}
// Then fire several capture to lock the AE.
requestBuilder.set(CaptureRequest.CONTROL_AE_LOCK, true);
int requestCount = captureRequestsSynchronized(requestBuilder.build(), numCapturesDuringLock, listener, mHandler);
int[] sensitivities = new int[numCapturesDuringLock];
long[] expTimes = new long[numCapturesDuringLock];
Arrays.fill(sensitivities, -1);
Arrays.fill(expTimes, -1L);
// Get the AE lock on result and validate the exposure values.
waitForNumResults(listener, requestCount - numCapturesDuringLock);
for (int i = 0; i < resultsDuringLock.length; i++) {
resultsDuringLock[i] = listener.getCaptureResult(WAIT_FOR_RESULT_TIMEOUT_MS);
}
for (int i = 0; i < numCapturesDuringLock; i++) {
mCollector.expectKeyValueEquals(resultsDuringLock[i], CaptureResult.CONTROL_AE_LOCK, true);
}
// Can't read manual sensor/exposure settings without manual sensor
if (mStaticInfo.isCapabilitySupported(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS)) {
int sensitivityLocked = getValueNotNull(resultsDuringLock[0], CaptureResult.SENSOR_SENSITIVITY);
long expTimeLocked = getValueNotNull(resultsDuringLock[0], CaptureResult.SENSOR_EXPOSURE_TIME);
for (int i = 1; i < resultsDuringLock.length; i++) {
mCollector.expectKeyValueEquals(resultsDuringLock[i], CaptureResult.SENSOR_EXPOSURE_TIME, expTimeLocked);
mCollector.expectKeyValueEquals(resultsDuringLock[i], CaptureResult.SENSOR_SENSITIVITY, sensitivityLocked);
}
}
}
use of android.hardware.camera2.CaptureResult in project android_frameworks_base by AOSPA.
the class CameraMetadataTest method testCaptureResult.
@SmallTest
public void testCaptureResult() {
mMetadata.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH);
if (VERBOSE)
mMetadata.dumpToLog();
CaptureResult captureResult = new CaptureResult(mMetadata, /*sequenceId*/
0);
List<CaptureResult.Key<?>> allKeys = captureResult.getKeys();
if (VERBOSE)
Log.v(TAG, "testCaptureResult: key list size " + allKeys);
for (CaptureResult.Key<?> key : captureResult.getKeys()) {
if (VERBOSE) {
Log.v(TAG, "testCaptureResult: key " + key + " value" + captureResult.get(key));
}
}
// FIXME: android.statistics.faces counts as a key
assertTrue(allKeys.size() >= 1);
assertTrue(allKeys.contains(CaptureResult.CONTROL_AE_MODE));
assertEquals(CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH, (int) captureResult.get(CaptureResult.CONTROL_AE_MODE));
}
use of android.hardware.camera2.CaptureResult in project platform_frameworks_base by android.
the class Camera2SwitchPreviewTest method stillCapturePreviewPreparer.
private void stillCapturePreviewPreparer(String id) throws Exception {
CaptureResult result;
SimpleCaptureCallback resultListener = new SimpleCaptureCallback();
SimpleImageReaderListener imageListener = new SimpleImageReaderListener();
CaptureRequest.Builder previewRequest = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
CaptureRequest.Builder stillRequest = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
// Preview Setup:
prepareCapturePreview(previewRequest, stillRequest, resultListener, imageListener);
Thread.sleep(getTestWaitIntervalMs());
}
Aggregations