Methods Summary |
---|
private static boolean | areValuesAllNull(java.lang.Object objs)Check if input arguments are all {@code null}.
for (Object o : objs) {
if (o != null) return false;
}
return true;
|
private void | close()
// this sets mMetadataPtr to 0
nativeClose();
mMetadataPtr = 0; // set it to 0 again to prevent eclipse from making this field final
|
public int | describeContents()
return 0;
|
public void | dumpToLog()Dumps the native metadata contents to logcat.
Visibility for testing/debugging only. The results will not
include any synthesized keys, as they are invisible to the native layer.
try {
nativeDump();
} catch (IOException e) {
Log.wtf(TAG, "Dump logging failed", e);
}
|
protected void | finalize()
try {
close();
} finally {
super.finalize();
}
|
public T | get(CaptureRequest.Key key)
return get(key.getNativeKey());
|
public T | get(android.hardware.camera2.impl.CameraMetadataNative$Key key)Look-up a metadata field value by its key.
Preconditions.checkNotNull(key, "key must not be null");
// Check if key has been overridden to use a wrapper class on the java side.
GetCommand g = sGetCommandMap.get(key);
if (g != null) {
return g.getValue(this, key);
}
return getBase(key);
|
public T | get(CameraCharacteristics.Key key)
return get(key.getNativeKey());
|
public T | get(CaptureResult.Key key)
return get(key.getNativeKey());
|
private int[] | getAvailableFormats()
sGetCommandMap.put(
CameraCharacteristics.SCALER_AVAILABLE_FORMATS.getNativeKey(), new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getAvailableFormats();
}
});
sGetCommandMap.put(
CaptureResult.STATISTICS_FACES.getNativeKey(), new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getFaces();
}
});
sGetCommandMap.put(
CaptureResult.STATISTICS_FACE_RECTANGLES.getNativeKey(), new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getFaceRectangles();
}
});
sGetCommandMap.put(
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP.getNativeKey(),
new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getStreamConfigurationMap();
}
});
sGetCommandMap.put(
CameraCharacteristics.CONTROL_MAX_REGIONS_AE.getNativeKey(), new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getMaxRegions(key);
}
});
sGetCommandMap.put(
CameraCharacteristics.CONTROL_MAX_REGIONS_AWB.getNativeKey(), new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getMaxRegions(key);
}
});
sGetCommandMap.put(
CameraCharacteristics.CONTROL_MAX_REGIONS_AF.getNativeKey(), new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getMaxRegions(key);
}
});
sGetCommandMap.put(
CameraCharacteristics.REQUEST_MAX_NUM_OUTPUT_RAW.getNativeKey(), new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getMaxNumOutputs(key);
}
});
sGetCommandMap.put(
CameraCharacteristics.REQUEST_MAX_NUM_OUTPUT_PROC.getNativeKey(), new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getMaxNumOutputs(key);
}
});
sGetCommandMap.put(
CameraCharacteristics.REQUEST_MAX_NUM_OUTPUT_PROC_STALLING.getNativeKey(),
new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getMaxNumOutputs(key);
}
});
sGetCommandMap.put(
CaptureRequest.TONEMAP_CURVE.getNativeKey(), new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getTonemapCurve();
}
});
sGetCommandMap.put(
CaptureResult.JPEG_GPS_LOCATION.getNativeKey(), new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getGpsLocation();
}
});
sGetCommandMap.put(
CaptureResult.STATISTICS_LENS_SHADING_CORRECTION_MAP.getNativeKey(),
new GetCommand() {
@Override
@SuppressWarnings("unchecked")
public <T> T getValue(CameraMetadataNative metadata, Key<T> key) {
return (T) metadata.getLensShadingMap();
}
});
int[] availableFormats = getBase(CameraCharacteristics.SCALER_AVAILABLE_FORMATS);
if (availableFormats != null) {
for (int i = 0; i < availableFormats.length; i++) {
// JPEG has different value between native and managed side, need override.
if (availableFormats[i] == NATIVE_JPEG_FORMAT) {
availableFormats[i] = ImageFormat.JPEG;
}
}
}
return availableFormats;
|
private T | getBase(CameraCharacteristics.Key key)
return getBase(key.getNativeKey());
|
private T | getBase(CaptureResult.Key key)
return getBase(key.getNativeKey());
|
private T | getBase(CaptureRequest.Key key)
return getBase(key.getNativeKey());
|
private T | getBase(android.hardware.camera2.impl.CameraMetadataNative$Key key)
int tag = key.getTag();
byte[] values = readValues(tag);
if (values == null) {
return null;
}
Marshaler<T> marshaler = getMarshalerForKey(key);
ByteBuffer buffer = ByteBuffer.wrap(values).order(ByteOrder.nativeOrder());
return marshaler.unmarshal(buffer);
|
public int | getEntryCount()
return nativeGetEntryCount();
|
private android.graphics.Rect[] | getFaceRectangles()
Rect[] faceRectangles = getBase(CaptureResult.STATISTICS_FACE_RECTANGLES);
if (faceRectangles == null) return null;
Rect[] fixedFaceRectangles = new Rect[faceRectangles.length];
for (int i = 0; i < faceRectangles.length; i++) {
fixedFaceRectangles[i] = new Rect(
faceRectangles[i].left,
faceRectangles[i].top,
faceRectangles[i].right - faceRectangles[i].left,
faceRectangles[i].bottom - faceRectangles[i].top);
}
return fixedFaceRectangles;
|
private android.hardware.camera2.params.Face[] | getFaces()
Integer faceDetectMode = get(CaptureResult.STATISTICS_FACE_DETECT_MODE);
byte[] faceScores = get(CaptureResult.STATISTICS_FACE_SCORES);
Rect[] faceRectangles = get(CaptureResult.STATISTICS_FACE_RECTANGLES);
int[] faceIds = get(CaptureResult.STATISTICS_FACE_IDS);
int[] faceLandmarks = get(CaptureResult.STATISTICS_FACE_LANDMARKS);
if (areValuesAllNull(faceDetectMode, faceScores, faceRectangles, faceIds, faceLandmarks)) {
return null;
}
if (faceDetectMode == null) {
Log.w(TAG, "Face detect mode metadata is null, assuming the mode is SIMPLE");
faceDetectMode = CaptureResult.STATISTICS_FACE_DETECT_MODE_SIMPLE;
} else {
if (faceDetectMode == CaptureResult.STATISTICS_FACE_DETECT_MODE_OFF) {
return new Face[0];
}
if (faceDetectMode != CaptureResult.STATISTICS_FACE_DETECT_MODE_SIMPLE &&
faceDetectMode != CaptureResult.STATISTICS_FACE_DETECT_MODE_FULL) {
Log.w(TAG, "Unknown face detect mode: " + faceDetectMode);
return new Face[0];
}
}
// Face scores and rectangles are required by SIMPLE and FULL mode.
if (faceScores == null || faceRectangles == null) {
Log.w(TAG, "Expect face scores and rectangles to be non-null");
return new Face[0];
} else if (faceScores.length != faceRectangles.length) {
Log.w(TAG, String.format("Face score size(%d) doesn match face rectangle size(%d)!",
faceScores.length, faceRectangles.length));
}
// To be safe, make number of faces is the minimal of all face info metadata length.
int numFaces = Math.min(faceScores.length, faceRectangles.length);
// Face id and landmarks are only required by FULL mode.
if (faceDetectMode == CaptureResult.STATISTICS_FACE_DETECT_MODE_FULL) {
if (faceIds == null || faceLandmarks == null) {
Log.w(TAG, "Expect face ids and landmarks to be non-null for FULL mode," +
"fallback to SIMPLE mode");
faceDetectMode = CaptureResult.STATISTICS_FACE_DETECT_MODE_SIMPLE;
} else {
if (faceIds.length != numFaces ||
faceLandmarks.length != numFaces * FACE_LANDMARK_SIZE) {
Log.w(TAG, String.format("Face id size(%d), or face landmark size(%d) don't" +
"match face number(%d)!",
faceIds.length, faceLandmarks.length * FACE_LANDMARK_SIZE, numFaces));
}
// To be safe, make number of faces is the minimal of all face info metadata length.
numFaces = Math.min(numFaces, faceIds.length);
numFaces = Math.min(numFaces, faceLandmarks.length / FACE_LANDMARK_SIZE);
}
}
ArrayList<Face> faceList = new ArrayList<Face>();
if (faceDetectMode == CaptureResult.STATISTICS_FACE_DETECT_MODE_SIMPLE) {
for (int i = 0; i < numFaces; i++) {
if (faceScores[i] <= Face.SCORE_MAX &&
faceScores[i] >= Face.SCORE_MIN) {
faceList.add(new Face(faceRectangles[i], faceScores[i]));
}
}
} else {
// CaptureResult.STATISTICS_FACE_DETECT_MODE_FULL
for (int i = 0; i < numFaces; i++) {
if (faceScores[i] <= Face.SCORE_MAX &&
faceScores[i] >= Face.SCORE_MIN &&
faceIds[i] >= 0) {
Point leftEye = new Point(faceLandmarks[i*FACE_LANDMARK_SIZE],
faceLandmarks[i*FACE_LANDMARK_SIZE+1]);
Point rightEye = new Point(faceLandmarks[i*FACE_LANDMARK_SIZE+2],
faceLandmarks[i*FACE_LANDMARK_SIZE+3]);
Point mouth = new Point(faceLandmarks[i*FACE_LANDMARK_SIZE+4],
faceLandmarks[i*FACE_LANDMARK_SIZE+5]);
Face face = new Face(faceRectangles[i], faceScores[i], faceIds[i],
leftEye, rightEye, mouth);
faceList.add(face);
}
}
}
Face[] faces = new Face[faceList.size()];
faceList.toArray(faces);
return faces;
|
private android.location.Location | getGpsLocation()
String processingMethod = get(CaptureResult.JPEG_GPS_PROCESSING_METHOD);
double[] coords = get(CaptureResult.JPEG_GPS_COORDINATES);
Long timeStamp = get(CaptureResult.JPEG_GPS_TIMESTAMP);
if (areValuesAllNull(processingMethod, coords, timeStamp)) {
return null;
}
Location l = new Location(translateProcessToLocationProvider(processingMethod));
if (timeStamp != null) {
l.setTime(timeStamp);
} else {
Log.w(TAG, "getGpsLocation - No timestamp for GPS location.");
}
if (coords != null) {
l.setLatitude(coords[0]);
l.setLongitude(coords[1]);
l.setAltitude(coords[2]);
} else {
Log.w(TAG, "getGpsLocation - No coordinates for GPS location");
}
return l;
|
private android.hardware.camera2.params.LensShadingMap | getLensShadingMap()
float[] lsmArray = getBase(CaptureResult.STATISTICS_LENS_SHADING_MAP);
Size s = get(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE);
// Do not warn if lsmArray is null while s is not. This is valid.
if (lsmArray == null) {
return null;
}
if (s == null) {
Log.w(TAG, "getLensShadingMap - Lens shading map size was null.");
return null;
}
LensShadingMap map = new LensShadingMap(lsmArray, s.getHeight(), s.getWidth());
return map;
|
private static android.hardware.camera2.marshal.Marshaler | getMarshalerForKey(android.hardware.camera2.impl.CameraMetadataNative$Key key)Get the marshaler compatible with the {@code key} and type {@code T}.
return MarshalRegistry.getMarshaler(key.getTypeReference(),
getNativeType(key.getTag()));
|
private java.lang.Integer | getMaxNumOutputs(android.hardware.camera2.impl.CameraMetadataNative$Key key)
final int RAW = 0;
final int PROC = 1;
final int PROC_STALLING = 2;
// The order of the elements is: (raw, proc+nonstalling, proc+stalling)
int[] maxNumOutputs = getBase(CameraCharacteristics.REQUEST_MAX_NUM_OUTPUT_STREAMS);
if (maxNumOutputs == null) {
return null;
}
if (key.equals(CameraCharacteristics.REQUEST_MAX_NUM_OUTPUT_RAW)) {
return maxNumOutputs[RAW];
} else if (key.equals(CameraCharacteristics.REQUEST_MAX_NUM_OUTPUT_PROC)) {
return maxNumOutputs[PROC];
} else if (key.equals(CameraCharacteristics.REQUEST_MAX_NUM_OUTPUT_PROC_STALLING)) {
return maxNumOutputs[PROC_STALLING];
} else {
throw new AssertionError("Invalid key " + key);
}
|
private java.lang.Integer | getMaxRegions(android.hardware.camera2.impl.CameraMetadataNative$Key key)
final int AE = 0;
final int AWB = 1;
final int AF = 2;
// The order of the elements is: (AE, AWB, AF)
int[] maxRegions = getBase(CameraCharacteristics.CONTROL_MAX_REGIONS);
if (maxRegions == null) {
return null;
}
if (key.equals(CameraCharacteristics.CONTROL_MAX_REGIONS_AE)) {
return maxRegions[AE];
} else if (key.equals(CameraCharacteristics.CONTROL_MAX_REGIONS_AWB)) {
return maxRegions[AWB];
} else if (key.equals(CameraCharacteristics.CONTROL_MAX_REGIONS_AF)) {
return maxRegions[AF];
} else {
throw new AssertionError("Invalid key " + key);
}
|
public static int | getNativeType(int tag)Get the underlying native type for a tag.
return nativeGetTypeFromTag(tag);
|
private android.hardware.camera2.params.StreamConfigurationMap | getStreamConfigurationMap()
StreamConfiguration[] configurations = getBase(
CameraCharacteristics.SCALER_AVAILABLE_STREAM_CONFIGURATIONS);
StreamConfigurationDuration[] minFrameDurations = getBase(
CameraCharacteristics.SCALER_AVAILABLE_MIN_FRAME_DURATIONS);
StreamConfigurationDuration[] stallDurations = getBase(
CameraCharacteristics.SCALER_AVAILABLE_STALL_DURATIONS);
HighSpeedVideoConfiguration[] highSpeedVideoConfigurations = getBase(
CameraCharacteristics.CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS);
return new StreamConfigurationMap(
configurations, minFrameDurations, stallDurations, highSpeedVideoConfigurations);
|
public static int | getTag(java.lang.String key)Convert a key string into the equivalent native tag.
return nativeGetTagFromKey(key);
|
private android.hardware.camera2.params.TonemapCurve | getTonemapCurve()
float[] red = getBase(CaptureRequest.TONEMAP_CURVE_RED);
float[] green = getBase(CaptureRequest.TONEMAP_CURVE_GREEN);
float[] blue = getBase(CaptureRequest.TONEMAP_CURVE_BLUE);
if (areValuesAllNull(red, green, blue)) {
return null;
}
if (red == null || green == null || blue == null) {
Log.w(TAG, "getTonemapCurve - missing tone curve components");
return null;
}
TonemapCurve tc = new TonemapCurve(red, green, blue);
return tc;
|
public boolean | isEmpty()Does this metadata contain at least 1 entry?
return nativeIsEmpty();
|
public static android.hardware.camera2.impl.CameraMetadataNative | move(android.hardware.camera2.impl.CameraMetadataNative other)Move the contents from {@code other} into a new camera metadata instance.
After this call, {@code other} will become empty.
CameraMetadataNative newObject = new CameraMetadataNative();
newObject.swap(other);
return newObject;
|
private native long | nativeAllocate()
|
private native long | nativeAllocateCopy(android.hardware.camera2.impl.CameraMetadataNative other)
|
private static native void | nativeClassInit()
|
private native synchronized void | nativeClose()
|
private native synchronized void | nativeDump()
|
private native synchronized int | nativeGetEntryCount()
|
private static native int | nativeGetTagFromKey(java.lang.String keyName)
|
private static native int | nativeGetTypeFromTag(int tag)
|
private native synchronized boolean | nativeIsEmpty()
|
private native synchronized void | nativeReadFromParcel(android.os.Parcel source)
|
private native synchronized byte[] | nativeReadValues(int tag)
|
public static native int | nativeSetupGlobalVendorTagDescriptor()Set the global client-side vendor tag descriptor to allow use of vendor
tags in camera applications.
|
private native synchronized void | nativeSwap(android.hardware.camera2.impl.CameraMetadataNative other)
|
private native synchronized void | nativeWriteToParcel(android.os.Parcel dest)
|
private native synchronized void | nativeWriteValues(int tag, byte[] src)
|
public void | readFromParcel(android.os.Parcel in)
nativeReadFromParcel(in);
|
public byte[] | readValues(int tag)Returns a byte[] of data corresponding to this tag. Use a wrapped bytebuffer to unserialize
the data properly.
An empty array can be returned to denote an existing entry with 0 elements.
// TODO: Optimization. Native code returns a ByteBuffer instead.
return nativeReadValues(tag);
|
private static void | registerAllMarshalers()
if (VERBOSE) {
Log.v(TAG, "Shall register metadata marshalers");
}
MarshalQueryable[] queryList = new MarshalQueryable[] {
// marshalers for standard types
new MarshalQueryablePrimitive(),
new MarshalQueryableEnum(),
new MarshalQueryableArray(),
// pseudo standard types, that expand/narrow the native type into a managed type
new MarshalQueryableBoolean(),
new MarshalQueryableNativeByteToInteger(),
// marshalers for custom types
new MarshalQueryableRect(),
new MarshalQueryableSize(),
new MarshalQueryableSizeF(),
new MarshalQueryableString(),
new MarshalQueryableReprocessFormatsMap(),
new MarshalQueryableRange(),
new MarshalQueryablePair(),
new MarshalQueryableMeteringRectangle(),
new MarshalQueryableColorSpaceTransform(),
new MarshalQueryableStreamConfiguration(),
new MarshalQueryableStreamConfigurationDuration(),
new MarshalQueryableRggbChannelVector(),
new MarshalQueryableBlackLevelPattern(),
new MarshalQueryableHighSpeedVideoConfiguration(),
// generic parcelable marshaler (MUST BE LAST since it has lowest priority)
new MarshalQueryableParcelable(),
};
for (MarshalQueryable query : queryList) {
MarshalRegistry.registerMarshalQueryable(query);
}
if (VERBOSE) {
Log.v(TAG, "Registered metadata marshalers");
}
|
public void | set(android.hardware.camera2.impl.CameraMetadataNative$Key key, T value)Set a camera metadata field to a value. The field definitions can be
found in {@link CameraCharacteristics}, {@link CaptureResult}, and
{@link CaptureRequest}.
SetCommand s = sSetCommandMap.get(key);
if (s != null) {
s.setValue(this, value);
return;
}
setBase(key, value);
|
public void | set(CaptureRequest.Key key, T value)
set(key.getNativeKey(), value);
|
public void | set(CaptureResult.Key key, T value)
set(key.getNativeKey(), value);
|
public void | set(CameraCharacteristics.Key key, T value)
set(key.getNativeKey(), value);
|
private boolean | setAvailableFormats(int[] value)
sSetCommandMap.put(CameraCharacteristics.SCALER_AVAILABLE_FORMATS.getNativeKey(),
new SetCommand() {
@Override
public <T> void setValue(CameraMetadataNative metadata, T value) {
metadata.setAvailableFormats((int[]) value);
}
});
sSetCommandMap.put(CaptureResult.STATISTICS_FACE_RECTANGLES.getNativeKey(),
new SetCommand() {
@Override
public <T> void setValue(CameraMetadataNative metadata, T value) {
metadata.setFaceRectangles((Rect[]) value);
}
});
sSetCommandMap.put(CaptureResult.STATISTICS_FACES.getNativeKey(),
new SetCommand() {
@Override
public <T> void setValue(CameraMetadataNative metadata, T value) {
metadata.setFaces((Face[])value);
}
});
sSetCommandMap.put(CaptureRequest.TONEMAP_CURVE.getNativeKey(), new SetCommand() {
@Override
public <T> void setValue(CameraMetadataNative metadata, T value) {
metadata.setTonemapCurve((TonemapCurve) value);
}
});
sSetCommandMap.put(CaptureResult.JPEG_GPS_LOCATION.getNativeKey(), new SetCommand() {
@Override
public <T> void setValue(CameraMetadataNative metadata, T value) {
metadata.setGpsLocation((Location) value);
}
});
int[] availableFormat = value;
if (value == null) {
// Let setBase() to handle the null value case.
return false;
}
int[] newValues = new int[availableFormat.length];
for (int i = 0; i < availableFormat.length; i++) {
newValues[i] = availableFormat[i];
if (availableFormat[i] == ImageFormat.JPEG) {
newValues[i] = NATIVE_JPEG_FORMAT;
}
}
setBase(CameraCharacteristics.SCALER_AVAILABLE_FORMATS, newValues);
return true;
|
private void | setBase(CameraCharacteristics.Key key, T value)
setBase(key.getNativeKey(), value);
|
private void | setBase(CaptureResult.Key key, T value)
setBase(key.getNativeKey(), value);
|
private void | setBase(CaptureRequest.Key key, T value)
setBase(key.getNativeKey(), value);
|
private void | setBase(android.hardware.camera2.impl.CameraMetadataNative$Key key, T value)
int tag = key.getTag();
if (value == null) {
// Erase the entry
writeValues(tag, /*src*/null);
return;
} // else update the entry to a new value
Marshaler<T> marshaler = getMarshalerForKey(key);
int size = marshaler.calculateMarshalSize(value);
// TODO: Optimization. Cache the byte[] and reuse if the size is big enough.
byte[] values = new byte[size];
ByteBuffer buffer = ByteBuffer.wrap(values).order(ByteOrder.nativeOrder());
marshaler.marshal(value, buffer);
writeValues(tag, values);
|
private boolean | setFaceRectangles(android.graphics.Rect[] faceRects)Convert Face Rectangles from managed side to native side as they have different definitions.
Managed side face rectangles are defined as: left, top, width, height.
Native side face rectangles are defined as: left, top, right, bottom.
The input face rectangle need to be converted to native side definition when set is called.
if (faceRects == null) {
return false;
}
Rect[] newFaceRects = new Rect[faceRects.length];
for (int i = 0; i < newFaceRects.length; i++) {
newFaceRects[i] = new Rect(
faceRects[i].left,
faceRects[i].top,
faceRects[i].right + faceRects[i].left,
faceRects[i].bottom + faceRects[i].top);
}
setBase(CaptureResult.STATISTICS_FACE_RECTANGLES, newFaceRects);
return true;
|
private boolean | setFaces(android.hardware.camera2.params.Face[] faces)
if (faces == null) {
return false;
}
int numFaces = faces.length;
// Detect if all faces are SIMPLE or not; count # of valid faces
boolean fullMode = true;
for (Face face : faces) {
if (face == null) {
numFaces--;
Log.w(TAG, "setFaces - null face detected, skipping");
continue;
}
if (face.getId() == Face.ID_UNSUPPORTED) {
fullMode = false;
}
}
Rect[] faceRectangles = new Rect[numFaces];
byte[] faceScores = new byte[numFaces];
int[] faceIds = null;
int[] faceLandmarks = null;
if (fullMode) {
faceIds = new int[numFaces];
faceLandmarks = new int[numFaces * FACE_LANDMARK_SIZE];
}
int i = 0;
for (Face face : faces) {
if (face == null) {
continue;
}
faceRectangles[i] = face.getBounds();
faceScores[i] = (byte)face.getScore();
if (fullMode) {
faceIds[i] = face.getId();
int j = 0;
faceLandmarks[i * FACE_LANDMARK_SIZE + j++] = face.getLeftEyePosition().x;
faceLandmarks[i * FACE_LANDMARK_SIZE + j++] = face.getLeftEyePosition().y;
faceLandmarks[i * FACE_LANDMARK_SIZE + j++] = face.getRightEyePosition().x;
faceLandmarks[i * FACE_LANDMARK_SIZE + j++] = face.getRightEyePosition().y;
faceLandmarks[i * FACE_LANDMARK_SIZE + j++] = face.getMouthPosition().x;
faceLandmarks[i * FACE_LANDMARK_SIZE + j++] = face.getMouthPosition().y;
}
i++;
}
set(CaptureResult.STATISTICS_FACE_RECTANGLES, faceRectangles);
set(CaptureResult.STATISTICS_FACE_IDS, faceIds);
set(CaptureResult.STATISTICS_FACE_LANDMARKS, faceLandmarks);
set(CaptureResult.STATISTICS_FACE_SCORES, faceScores);
return true;
|
private boolean | setGpsLocation(android.location.Location l)
if (l == null) {
return false;
}
double[] coords = { l.getLatitude(), l.getLongitude(), l.getAltitude() };
String processMethod = translateLocationProviderToProcess(l.getProvider());
long timestamp = l.getTime();
set(CaptureRequest.JPEG_GPS_TIMESTAMP, timestamp);
set(CaptureRequest.JPEG_GPS_COORDINATES, coords);
if (processMethod == null) {
Log.w(TAG, "setGpsLocation - No process method, Location is not from a GPS or NETWORK" +
"provider");
} else {
setBase(CaptureRequest.JPEG_GPS_PROCESSING_METHOD, processMethod);
}
return true;
|
private boolean | setTonemapCurve(android.hardware.camera2.params.TonemapCurve tc)
if (tc == null) {
return false;
}
float[][] curve = new float[3][];
for (int i = TonemapCurve.CHANNEL_RED; i <= TonemapCurve.CHANNEL_BLUE; i++) {
int pointCount = tc.getPointCount(i);
curve[i] = new float[pointCount * TonemapCurve.POINT_SIZE];
tc.copyColorCurve(i, curve[i], 0);
}
setBase(CaptureRequest.TONEMAP_CURVE_RED, curve[0]);
setBase(CaptureRequest.TONEMAP_CURVE_GREEN, curve[1]);
setBase(CaptureRequest.TONEMAP_CURVE_BLUE, curve[2]);
return true;
|
public void | swap(android.hardware.camera2.impl.CameraMetadataNative other)Perform a 0-copy swap of the internal metadata with another object.
Useful to convert a CameraMetadata into e.g. a CaptureRequest.
nativeSwap(other);
|
private static java.lang.String | translateLocationProviderToProcess(java.lang.String provider)
if (provider == null) {
return null;
}
switch(provider) {
case LocationManager.GPS_PROVIDER:
return GPS_PROCESS;
case LocationManager.NETWORK_PROVIDER:
return CELLID_PROCESS;
default:
return null;
}
|
private static java.lang.String | translateProcessToLocationProvider(java.lang.String process)
if (process == null) {
return null;
}
switch(process) {
case GPS_PROCESS:
return LocationManager.GPS_PROVIDER;
case CELLID_PROCESS:
return LocationManager.NETWORK_PROVIDER;
default:
return null;
}
|
public void | writeToParcel(android.os.Parcel dest, int flags)
nativeWriteToParcel(dest);
|
public void | writeValues(int tag, byte[] src)Updates the existing entry for tag with the new bytes pointed by src, erasing
the entry if src was null.
An empty array can be passed in to update the entry to 0 elements.
nativeWriteValues(tag, src);
|