# Camera2Source

@RequiresApi(value = 21)
class Camera2Source(context: Context) : VideoSource

Created by pedro on 11/1/24.

## Constructors

Camera2Source
Link copied to clipboard
constructor(context: Context)

## Properties

created
Link copied to clipboard
var created: Boolean
fps
Link copied to clipboard
var fps: Int
height
Link copied to clipboard
var height: Int
rotation
Link copied to clipboard
var rotation: Int
surfaceTexture
Link copied to clipboard
var surfaceTexture: SurfaceTexture?
width
Link copied to clipboard
var width: Int

## Functions

addImageListener
Link copied to clipboard
@JvmOverloads
fun addImageListener(format: Int, maxImages: Int, autoClose: Boolean = true, listener: Camera2ApiManager.ImageCallback)
camerasAvailable
Link copied to clipboard
fun camerasAvailable(): Array<String>
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(callback: 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>
getCameraFacing
Link copied to clipboard
fun getCameraFacing(): CameraHelper.Facing
getCameraResolutions
Link copied to clipboard
fun getCameraResolutions(facing: CameraHelper.Facing): List<Size>
getCurrentCameraId
Link copied to clipboard
fun getCurrentCameraId(): String
getExposure
Link copied to clipboard
fun getExposure(): Int
getMaxSupportedFps
Link copied to clipboard
@JvmOverloads
fun getMaxSupportedFps(size: Size?, facing: CameraHelper.Facing = getCameraFacing()): Int
getOrientationConfig
Link copied to clipboard
open fun getOrientationConfig(): OrientationConfig
getWhiteBalance
Link copied to clipboard
fun getWhiteBalance(): Int
getZoom
Link copied to clipboard
fun getZoom(): Float
getZoomRange
Link copied to clipboard
fun getZoomRange(): Range<Float>
init
Link copied to clipboard
fun init(width: Int, height: Int, fps: Int, rotation: Int): Boolean
isAutoExposureEnabled
Link copied to clipboard
fun isAutoExposureEnabled(): Boolean
isAutoFocusEnabled
Link copied to clipboard
fun isAutoFocusEnabled(): Boolean
isAutoWhiteBalanceEnabled
Link copied to clipboard
fun isAutoWhiteBalanceEnabled(): Boolean
isFaceDetectionEnabled
Link copied to clipboard
fun isFaceDetectionEnabled(): Boolean
isLanternEnabled
Link copied to clipboard
fun isLanternEnabled(): Boolean
isOpticalVideoStabilizationEnabled
Link copied to clipboard
fun isOpticalVideoStabilizationEnabled(): Boolean
isRunning
Link copied to clipboard
open override fun isRunning(): Boolean
isVideoStabilizationEnabled
Link copied to clipboard
fun isVideoStabilizationEnabled(): Boolean
openCameraId
Link copied to clipboard
fun openCameraId(id: String)
openPhysicalCamera
Link copied to clipboard
@RequiresApi(value = 28)
fun openPhysicalCamera(id: String?)
physicalCamerasAvailable
Link copied to clipboard
@RequiresApi(value = 28)
fun physicalCamerasAvailable(): List<String>
release
Link copied to clipboard
open override fun release()
removeImageListener
Link copied to clipboard
fun removeImageListener()
restart
Link copied to clipboard
fun restart(): Boolean

Re start camera if possible, return true or false depend if can do it or not.

setAvailabilityCallback
Link copied to clipboard
fun setAvailabilityCallback(callback: CameraManager.AvailabilityCallback?)

Add a callback to detect the camera availability. Set null value to remove the callback

setCameraCallback
Link copied to clipboard
fun setCameraCallback(callbacks: CameraCallbacks?)
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
setExposure
Link copied to clipboard
fun setExposure(level: Int)
setRequiredResolution
Link copied to clipboard
fun setRequiredResolution(size: Size?)

Set the required resolution for the camera. Must be called before prepareVideo or changeVideoSource. Otherwise it will be ignored.

setZoom
Link copied to clipboard
fun setZoom(level: Float)
@JvmOverloads
fun setZoom(event: MotionEvent, delta: Float = 0.1f)
start
Link copied to clipboard
open override fun start(surfaceTexture: SurfaceTexture)
stop
Link copied to clipboard
open override fun stop()
switchCamera
Link copied to clipboard
fun switchCamera()
tapToFocus
Link copied to clipboard
fun tapToFocus(view: View, event: MotionEvent): Boolean