我只想在textureView中显示相机预览.
在纵向模式下它看起来很好但在横向模式下它顺时针旋转90度.
我知道这样的事情可以解决这个问题:
private static final SparseIntArray ORIENTATIONS = new SparseIntArray();
static {
ORIENTATIONS.append(Surface.ROTATION_0, 90);
ORIENTATIONS.append(Surface.ROTATION_90, 0);
ORIENTATIONS.append(Surface.ROTATION_180, 270);
ORIENTATIONS.append(Surface.ROTATION_270, 180);
}
我不知道在哪里打电话.你有什么建议吗?
这是我的代码:
private TextureView textureView;
private static final String TAG = "AndroidCameraApi";
private String cameraId;
protected CameraDevice cameraDevice;
protected CameraCaptureSession cameraCaptureSessions;
protected CaptureRequest captureRequest;
private static final int REQUEST_CAMERA_PERMISSION = 200;
private Size imageDimension;
protected CaptureRequest.Builder captureRequestBuilder;
private Handler mBackgroundHandler;
private HandlerThread mBackgroundThread;
private ImageReader imageReader;
private static final SparseIntArray ORIENTATIONS = new SparseIntArray();
static {
ORIENTATIONS.append(Surface.ROTATION_0, 90);
ORIENTATIONS.append(Surface.ROTATION_90, 0);