本文整理匯總了Java中android.hardware.camera2.CameraAccessException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java CameraAccessException.printStackTrace方法的具體用法?Java CameraAccessException.printStackTrace怎麽用?Java CameraAccessException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.camera2.CameraAccessException
的用法示例。
在下文中一共展示了CameraAccessException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: closeCamera
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
@TargetApi(23)
@Override
public void closeCamera() {
textureView.setVisibility(View.GONE);
if (mDetectTimer != null) {
mDetectTimer.cancel();
}
if (cameraCaptureSession != null && isDetecting) {
try {
cameraCaptureSession.abortCaptures();
cameraCaptureSession.stopRepeating();
cameraCaptureSession.close();
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
if (cameraDevice != null) {
cameraDevice.close();
}
}
示例2: openCamera
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
private void openCamera(String cameraId) {
try {
// CameraCharacteristics characteristics = mCameraManager.getCameraCharacteristics(cameraId);
// characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
if (ActivityCompat.checkSelfPermission(getContext(), permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
setUpCameraOutputs(cameraId, ttv_camera.getWidth(), ttv_camera.getHeight());
configureTransform(ttv_camera.getWidth(), ttv_camera.getHeight());
mCameraManager.openCamera(cameraId, mCameraDeviceStateCallback, mHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例3: createCameraPreviewSession
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
private void createCameraPreviewSession() {
if (mCamera == null) {
return;
}
SurfaceHolder holder = surfaceView.getHolder();
// if (config != null) {
// holder.setFixedSize(640, 480);
// }
Surface surface = holder.getSurface();
List<Surface> surfaceList = Arrays.asList(surface, mImageReader.getSurface());
try {
mPreviewBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
mPreviewBuilder.addTarget(surface);
mCamera.createCaptureSession(surfaceList, sessionCallback, mHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例4: startPreview
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
private void startPreview() {
try {
CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId);
StreamConfigurationMap configMap = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
Size previewSize = Util.getPreferredPreviewSize(
configMap.getOutputSizes(ImageFormat.JPEG),textureView.getWidth(), textureView.getHeight());
surfaceTexture.setDefaultBufferSize(previewSize.getWidth(),previewSize.getHeight());
Surface surface = new Surface(surfaceTexture);
captureBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
captureBuilder.addTarget(surface);
cameraDevice.createCaptureSession(Arrays.asList(surface),captureSessionCallback,backgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例5: unlockFocus
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
/**
* Unlock the focus. This method should be called when still image capture sequence is
* finished.
*/
private void unlockFocus() {
try {
// Reset the auto-focus trigger
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
setAutoFlash(mPreviewRequestBuilder);
mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback,
mBackgroundHandler);
// After this, the camera will go back to the normal state of preview.
mState = STATE_PREVIEW;
mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback,
mBackgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例6: openCamera
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
/**
* 相機開啟
* @param width TextureView的寬度
* @param height TextureView的高度
*/
private void openCamera(int width, int height) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
// requestCameraPermission();
return;
}
setUpCameraOutputs(width, height);
configureTransform(width, height);
try {
cameraManager.openCamera(cameraID, deviceStateCallback, mainHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例7: lockFocus
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
/**
* Lock the focus as the first step for a still image capture.
*/
private void lockFocus() {
try {
// This is how to tell the camera to lock focus.
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
CameraMetadata.CONTROL_AF_TRIGGER_START);
// Tell #mCaptureCallback to wait for the lock.
mState = STATE_WAITING_LOCK;
mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback,
mBackgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例8: buildRequest
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
@Override
public void buildRequest(int type) {
try {
CaptureRequest.Builder builder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例9: runPrecaptureSequence
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
/**
* Run the precapture sequence for capturing a still image. This method should be called when
* we get a response in {@link #mCaptureCallback} from {@link #lockFocus()}.
*/
private void runPrecaptureSequence() {
try {
// This is how to tell the camera to trigger.
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START);
// Tell #mCaptureCallback to wait for the precapture sequence to be set.
mState = STATE_WAITING_PRECAPTURE;
mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例10: updatePreview
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
/**
* Update the camera preview. {@link #startPreview()} needs to be called in advance.
*/
private void updatePreview() {
if (null == mCameraDevice) {
return;
}
try {
setUpCaptureRequestBuilder(mPreviewBuilder);
HandlerThread thread = new HandlerThread("CameraPreview");
thread.start();
mPreviewSession.setRepeatingRequest(mPreviewBuilder.build(), null, mBackgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例11: takePicture
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
private void takePicture() {
if (mCameraDevice == null) {
return;
}
//創建Request.Builder()
final CaptureRequest.Builder requestBuilder ;
try{
requestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
//將ImageReader的surface作為CaptureRequest.Builder的目標
requestBuilder.addTarget(mImageReader.getSurface());
// 自動對焦
requestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
// 自動曝光
requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
requestBuilder.set(CaptureRequest.JPEG_ORIENTATION, 270);
//拍照
CaptureRequest mCaptureRequest = requestBuilder.build();
mCameraCaptureSession.capture(mCaptureRequest, null, null);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例12: runPrecaptureSequence
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
private void runPrecaptureSequence() {
MLog.d(TAG, "runPrecaptureSequence");
try {
// This is how to tell the camera to trigger.
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START);
// Tell #mCaptureCallback to wait for the precapture sequence to be set.
mState = STATE_WAITING_PRECAPTURE;
mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, null);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例13: unlockFocus
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
private void unlockFocus() {
MLog.d(TAG, "unlockFocus");
try {
// Reset the auto-focus trigger
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
//setAutoFlash(mPreviewRequestBuilder);
mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, null);
// After this, the camera will go back to the normal state of preview.
mState = STATE_PREVIEW;
mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, null);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例14: runPrecaptureSequence
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
/**
* Run the precapture sequence for capturing a still image. This method should be called when
* we get a response in {@link #mCaptureCallback} from {@link #lockFocus()}.
*/
private void runPrecaptureSequence() {
try {
// This is how to tell the camera to trigger.
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START);
// Tell #mCaptureCallback to wait for the precapture sequence to be set.
mState = STATE_WAITING_PRECAPTURE;
mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback,
mBackgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
示例15: onConfigured
import android.hardware.camera2.CameraAccessException; //導入方法依賴的package包/類
@Override
public void onConfigured(CameraCaptureSession session) {
mCameraCaptureSession = session;
try {
// 自動對焦
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
// 自動閃光燈
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
CaptureRequest previewRequest = mPreviewRequestBuilder.build();
session.setRepeatingRequest(previewRequest, null, mPreviewHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}