本文整理汇总了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();
}
}