本文整理匯總了Java中android.hardware.camera2.CaptureResult類的典型用法代碼示例。如果您正苦於以下問題:Java CaptureResult類的具體用法?Java CaptureResult怎麽用?Java CaptureResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CaptureResult類屬於android.hardware.camera2包,在下文中一共展示了CaptureResult類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: detectFaces
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
private void detectFaces(CaptureResult captureResult) {
Integer mode = captureResult.get(CaptureResult.STATISTICS_FACE_DETECT_MODE);
if (isViewAvailable() && mode != null) {
android.hardware.camera2.params.Face[] faces = captureResult.get(CaptureResult.STATISTICS_FACES);
if (faces != null) {
Log.i(TAG, "faces : " + faces.length + " , mode : " + mode);
for (android.hardware.camera2.params.Face face : faces) {
Rect faceBounds = face.getBounds();
// Once processed, the result is sent back to the View
presenterView.onFaceDetected(mapCameraFaceToCanvas(faceBounds, face.getLeftEyePosition(),
face.getRightEyePosition()));
}
}
}
}
示例2: checkState
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
private void checkState(CaptureResult result) {
/*switch (mState) {
case STATE_PREVIEW:
// NOTHING
break;
case STATE_WAITING_CAPTURE:
int afState = result.get(CaptureResult.CONTROL_AF_STATE);
if (CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState ||
CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState
|| CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED == afState
|| CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED == afState) {
//do something like save picture
}
break;
}*/
}
示例3: toFile
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
/**
* Generate a human-readable string of the given capture request and write
* it to the given file.
*/
public static void toFile(String title, CameraMetadata<?> metadata, File file) {
try {
// Will append if the file already exists.
FileWriter writer = new FileWriter(file, true);
if (metadata instanceof CaptureRequest) {
dumpMetadata(title, (CaptureRequest) metadata, writer);
} else if (metadata instanceof CaptureResult) {
dumpMetadata(title, (CaptureResult) metadata, writer);
} else {
writer.close();
throw new IllegalArgumentException("Cannot generate debug data from type "
+ metadata.getClass().getName());
}
writer.close();
} catch (IOException ex) {
Log.e(TAG, "Could not write capture data to file.", ex);
}
}
示例4: stateFromCamera2State
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
/**
* Convert reported camera2 AF state to OneCamera AutoFocusState.
*/
public static OneCamera.AutoFocusState stateFromCamera2State(int state) {
switch (state) {
case CaptureResult.CONTROL_AF_STATE_ACTIVE_SCAN:
return OneCamera.AutoFocusState.ACTIVE_SCAN;
case CaptureResult.CONTROL_AF_STATE_PASSIVE_SCAN:
return OneCamera.AutoFocusState.PASSIVE_SCAN;
case CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED:
return OneCamera.AutoFocusState.PASSIVE_FOCUSED;
case CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED:
return OneCamera.AutoFocusState.ACTIVE_FOCUSED;
case CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED:
return OneCamera.AutoFocusState.PASSIVE_UNFOCUSED;
case CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED:
return OneCamera.AutoFocusState.ACTIVE_UNFOCUSED;
default:
return OneCamera.AutoFocusState.INACTIVE;
}
}
示例5: controlAFStateToString
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
/**
* Utility function: converts CaptureResult.CONTROL_AF_STATE to String.
*/
private static String controlAFStateToString(int controlAFState) {
switch (controlAFState) {
case CaptureResult.CONTROL_AF_STATE_INACTIVE:
return "inactive";
case CaptureResult.CONTROL_AF_STATE_PASSIVE_SCAN:
return "passive_scan";
case CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED:
return "passive_focused";
case CaptureResult.CONTROL_AF_STATE_ACTIVE_SCAN:
return "active_scan";
case CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED:
return "focus_locked";
case CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED:
return "not_focus_locked";
case CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED:
return "passive_unfocused";
default:
return "unknown";
}
}
示例6: onImageCaptured
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
@Override
public void onImageCaptured(Image image, TotalCaptureResult
captureResult) {
long timestamp = captureResult.get(CaptureResult.SENSOR_TIMESTAMP);
// We should only capture the image if it's more recent than the
// latest one. Synchronization is necessary since this method is
// called on {@link #mImageSaverThreadPool}.
synchronized (mLastCapturedImageTimestamp) {
if (timestamp > mLastCapturedImageTimestamp.get()) {
mLastCapturedImageTimestamp.set(timestamp);
} else {
// There was a more recent (or identical) image which has
// begun being saved, so abort.
return;
}
}
mReadyStateManager.setInput(
ReadyStateRequirement.CAPTURE_NOT_IN_PROGRESS, true);
mSession.startEmpty();
savePicture(image, mParams, mSession);
mParams.callback.onPictureTaken(mSession);
Log.v(TAG, "Image saved. Frame number = " + captureResult.getFrameNumber());
}
示例7: process
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
private void process(CaptureResult captureResult) {
switch (mCaptureState) {
case STATE_PREVIEW:
// Do nothing
break;
case STATE_WAIT_LOCK:
mCaptureState = STATE_PREVIEW;
Integer afState = captureResult.get(CaptureResult.CONTROL_AF_STATE);
if(afState == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED ||
afState == CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) {
Toast.makeText(getApplicationContext(), "AF Locked!", Toast.LENGTH_SHORT).show();
startStillCaptureRequest();
}
break;
}
}
示例8: onCaptureProgressed
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
@Override
public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request,
CaptureResult partialResult) {
Log.d(TAG, "mSessionCaptureCallback, onCaptureProgressed");
mSession = session;
checkState(partialResult);
}
示例9: ImageSaver
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
private ImageSaver(Image image, File file, CaptureResult result,
CameraCharacteristics characteristics, Context context,
RefCountedAutoCloseable<ImageReader> reader) {
mImage = image;
mFile = file;
mCaptureResult = result;
mCharacteristics = characteristics;
mContext = context;
mReader = reader;
}
示例10: qq
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
public void qq() {
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_EFFECT_MODE, CaptureResult.CONTROL_EFFECT_MODE_MONO);
mPreviewRequest = mPreviewRequestBuilder.build();
try {
mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, null);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例11: checkControlAfState
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
/**
* Complain if CONTROL_AF_STATE is not present in result.
* Could indicate bug in API implementation.
*/
public static boolean checkControlAfState(CaptureResult result) {
boolean missing = result.get(CaptureResult.CONTROL_AF_STATE) == null;
if (missing) {
// throw new IllegalStateException("CaptureResult missing CONTROL_AF_STATE.");
Log.e(TAG, "\n!!!! TotalCaptureResult missing CONTROL_AF_STATE. !!!!\n ");
}
return !missing;
}
示例12: checkLensState
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
/**
* Complain if LENS_STATE is not present in result.
* Could indicate bug in API implementation.
*/
public static boolean checkLensState(CaptureResult result) {
boolean missing = result.get(CaptureResult.LENS_STATE) == null;
if (missing) {
// throw new IllegalStateException("CaptureResult missing LENS_STATE.");
Log.e(TAG, "\n!!!! TotalCaptureResult missing LENS_STATE. !!!!\n ");
}
return !missing;
}
示例13: logExtraFocusInfo
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
public static void logExtraFocusInfo(CaptureResult result) {
if(!checkControlAfState(result) || !checkLensState(result)) {
return;
}
Object tag = result.getRequest().getTag();
Log.v(TAG, String.format("af_state:%-17s lens_foc_dist:%.3f lens_state:%-10s %s",
controlAFStateToString(result.get(CaptureResult.CONTROL_AF_STATE)),
result.get(CaptureResult.LENS_FOCUS_DISTANCE),
lensStateToString(result.get(CaptureResult.LENS_STATE)),
(tag == null) ? "" : "[" + tag +"]"
));
}
示例14: lensStateToString
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
/**
* Utility function: converts CaptureResult.LENS_STATE to String.
*/
private static String lensStateToString(int lensState) {
switch (lensState) {
case CaptureResult.LENS_STATE_MOVING:
return "moving";
case CaptureResult.LENS_STATE_STATIONARY:
return "stationary";
default:
return "unknown";
}
}
示例15: onCaptureProgressed
import android.hardware.camera2.CaptureResult; //導入依賴的package包/類
@Override
public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request,
final CaptureResult partialResult) {
long frameNumber = partialResult.getFrameNumber();
// Update mMetadata for whichever keys are present, if this frame is
// supplying newer values.
for (final Key<?> key : partialResult.getKeys()) {
Pair<Long, Object> oldEntry = mMetadata.get(key);
final Object oldValue = (oldEntry != null) ? oldEntry.second : null;
boolean newerValueAlreadyExists = oldEntry != null
&& frameNumber < oldEntry.first;
if (newerValueAlreadyExists) {
continue;
}
final Object newValue = partialResult.get(key);
mMetadata.put(key, new Pair<Long, Object>(frameNumber, newValue));
// If the value has changed, call the appropriate listeners, if
// any exist.
if (oldValue == newValue || !mMetadataChangeListeners.containsKey(key)) {
continue;
}
for (final MetadataChangeListener listener :
mMetadataChangeListeners.get(key)) {
Log.v(TAG, "Dispatching to metadata change listener for key: "
+ key.toString());
mListenerHandler.post(new Runnable() {
@Override
public void run() {
listener.onImageMetadataChange(key, oldValue, newValue,
partialResult);
}
});
}
}
}