# Camera2ApiManager

@RequiresApi(api = 21)
class Camera2ApiManager(context: Context) : CameraDevice.StateCallback

Created by pedro on 4/03/17.

Class for use surfaceEncoder to buffer encoder. Advantage = you can use all resolutions. Disadvantages = you cant control fps of the stream, because you cant know when the inputSurface was renderer.

Note: you can use opengl for surfaceEncoder to buffer encoder on devices 21 < API > 16: https://github.com/google/grafika

## Constructors

Camera2ApiManager
Link copied to clipboard
constructor(context: Context)

## Types

ImageCallback
Link copied to clipboard
interface ImageCallback

## Properties

cameraCharacteristics
Link copied to clipboard
val cameraCharacteristics: CameraCharacteristics?
cameraFacing
Link copied to clipboard
var cameraFacing: CameraHelper.Facing
cameraResolutionsBack
Link copied to clipboard
val cameraResolutionsBack: Array<Size>
cameraResolutionsFront
Link copied to clipboard
val cameraResolutionsFront: Array<Size>
camerasAvailable
Link copied to clipboard
val camerasAvailable: Array<String>
exposure
Link copied to clipboard
var exposure: Int
isAutoExposureEnabled
Link copied to clipboard
var isAutoExposureEnabled: Boolean
isAutoFocusEnabled
Link copied to clipboard
var isAutoFocusEnabled: Boolean
isAutoWhiteBalanceEnabled
Link copied to clipboard
var isAutoWhiteBalanceEnabled: Boolean
isLanternEnabled
Link copied to clipboard
var isLanternEnabled: Boolean
isLanternSupported
Link copied to clipboard
val isLanternSupported: Boolean
isOpticalStabilizationEnabled
Link copied to clipboard
var isOpticalStabilizationEnabled: Boolean
isPrepared
Link copied to clipboard
var isPrepared: Boolean
isRunning
Link copied to clipboard
var isRunning: Boolean
isVideoStabilizationEnabled
Link copied to clipboard
var isVideoStabilizationEnabled: Boolean
levelSupported
Link copied to clipboard
val levelSupported: Int
maxExposure
Link copied to clipboard
val maxExposure: Int
minExposure
Link copied to clipboard
val minExposure: Int
zoom
Link copied to clipboard
var zoom: Float
zoomRange
Link copied to clipboard
val zoomRange: Range<Float>

## Functions

addImageListener
Link copied to clipboard
fun addImageListener(width: Int, height: Int, format: Int, maxImages: Int, autoClose: Boolean, listener: Camera2ApiManager.ImageCallback)
closeCamera
Link copied to clipboard
@JvmOverloads
fun closeCamera(resetSurface: Boolean = true)
disableAutoExposure
Link copied to clipboard
fun disableAutoExposure()
disableAutoFocus
Link copied to clipboard
fun disableAutoFocus(): Boolean
disableAutoWhiteBalance
Link copied to clipboard
fun disableAutoWhiteBalance()
disableFaceDetection
Link copied to clipboard
fun disableFaceDetection()
disableLantern
Link copied to clipboard
fun disableLantern()
disableOpticalVideoStabilization
Link copied to clipboard
fun disableOpticalVideoStabilization()
disableVideoStabilization
Link copied to clipboard
fun disableVideoStabilization()
enableAutoExposure
Link copied to clipboard
fun enableAutoExposure(): Boolean
enableAutoFocus
Link copied to clipboard
fun enableAutoFocus(): Boolean
enableAutoWhiteBalance
Link copied to clipboard
fun enableAutoWhiteBalance(mode: Int): Boolean
enableFaceDetection
Link copied to clipboard
fun enableFaceDetection(faceDetectorCallback: FaceDetectorCallback?): Boolean
enableFrameCaptureCallback
Link copied to clipboard
fun enableFrameCaptureCallback(frameCapturedCallback: FrameCapturedCallback?)
enableLantern
Link copied to clipboard
fun enableLantern()
enableOpticalVideoStabilization
Link copied to clipboard
fun enableOpticalVideoStabilization(): Boolean
enableVideoStabilization
Link copied to clipboard
fun enableVideoStabilization(): Boolean
getAutoWhiteBalanceModesAvailable
Link copied to clipboard
fun getAutoWhiteBalanceModesAvailable(): List<Int>
getCameraIdForFacing
Link copied to clipboard
@JvmOverloads
fun getCameraIdForFacing(facing: CameraHelper.Facing, cameraManager: CameraManager = this.cameraManager): String
getCameraResolutions
Link copied to clipboard
fun getCameraResolutions(facing: CameraHelper.Facing): Array<Size>
fun getCameraResolutions(cameraId: String): Array<Size>
getCurrentCameraId
Link copied to clipboard
fun getCurrentCameraId(): String
getOpticalZooms
Link copied to clipboard
fun getOpticalZooms(): FloatArray
getPhysicalCamerasAvailable
Link copied to clipboard
@RequiresApi(value = 28)
fun getPhysicalCamerasAvailable(): List<String>
getSupportedFps
Link copied to clipboard
fun getSupportedFps(size: Size?, facing: CameraHelper.Facing): List<Range<Int>>
getWhiteBalance
Link copied to clipboard
fun getWhiteBalance(): Int
isFaceDetectionEnabled
Link copied to clipboard
fun isFaceDetectionEnabled(): Boolean
onClosed
Link copied to clipboard
open fun onClosed(camera: CameraDevice)
onDisconnected
Link copied to clipboard
open override fun onDisconnected(cameraDevice: CameraDevice)
onError
Link copied to clipboard
open override fun onError(cameraDevice: CameraDevice, i: Int)
onOpened
Link copied to clipboard
open override fun onOpened(cameraDevice: CameraDevice)
openCameraBack
Link copied to clipboard
fun openCameraBack()
openCameraFacing
Link copied to clipboard
fun openCameraFacing(selectedCameraFacing: CameraHelper.Facing)

Select camera facing

openCameraFront
Link copied to clipboard
fun openCameraFront()
openCameraId
Link copied to clipboard
fun openCameraId(cameraId: String)
openLastCamera
Link copied to clipboard
fun openLastCamera()
openPhysicalCamera
Link copied to clipboard
@RequiresApi(value = 28)
fun openPhysicalCamera(id: String?)
prepareCamera
Link copied to clipboard
fun prepareCamera(surface: Surface, fps: Int)
fun prepareCamera(surfaceTexture: SurfaceTexture, width: Int, height: Int, fps: Int)
fun prepareCamera(surfaceTexture: SurfaceTexture, width: Int, height: Int, fps: Int, facing: CameraHelper.Facing)
fun prepareCamera(surfaceTexture: SurfaceTexture, width: Int, height: Int, fps: Int, cameraId: String)
removeImageListener
Link copied to clipboard
fun removeImageListener()
reOpenCamera
Link copied to clipboard
fun reOpenCamera(cameraId: String)
setAvailabilityCallback
Link copied to clipboard
fun setAvailabilityCallback(callback: CameraManager.AvailabilityCallback?)
setCameraCallbacks
Link copied to clipboard
fun setCameraCallbacks(cameraCallbacks: CameraCallbacks?)
setCameraId
Link copied to clipboard
fun setCameraId(cameraId: String)
setColorCorrectionGains
Link copied to clipboard
fun setColorCorrectionGains(red: Float, greenEven: Float, greenOdd: Float, blue: Float): Boolean
setCustomOnCaptureCompletedCallback
Link copied to clipboard
fun setCustomOnCaptureCompletedCallback(callback: (CameraCaptureSession, CaptureRequest, TotalCaptureResult) -> Unit?)
setCustomRequest
Link copied to clipboard
fun setCustomRequest(request: (CaptureRequest.Builder) -> Unit): Boolean
setFocusDistance
Link copied to clipboard
fun setFocusDistance(distance: Float)
setOpticalZoom
Link copied to clipboard
fun setOpticalZoom(level: Float)
setPhysicalCamera
Link copied to clipboard
@RequiresApi(value = 28)
fun setPhysicalCamera(id: String?)
setRequiredResolution
Link copied to clipboard
fun setRequiredResolution(size: Size?)
setZoom
Link copied to clipboard
@JvmOverloads
fun setZoom(event: MotionEvent, delta: Float = 0.1f)
switchCamera
Link copied to clipboard
fun switchCamera()
tapToFocus
Link copied to clipboard
fun tapToFocus(view: View, event: MotionEvent): Boolean