class CameraView
Platform and version requirements: JVM
CameraView(context: <ERROR CLASS>, attrs: <ERROR CLASS>? = null, defStyleAttr: Int = 0) |
var adjustViewBounds: Boolean
True when this CameraView is adjusting its bounds to preserve the aspect ratio of camera. |
|
var aspectRatio: AspectRatio
Set aspect ratio of camera. Valid format is "height:width" eg. "4:3". |
|
var autoFocus: Boolean
Set |
|
var awb: Int
Set auto white balance mode for preview and still captures. Supported values are Modes.AutoWhiteBalance. See android.hardware.camera2.CaptureRequest.CONTROL_AWB_MODE |
|
var cameraMode: Int
Set camera mode of operation. Supported values are Modes.CameraMode. |
|
var currentDigitalZoom: Float
Set digital zoom value. Must be between 1.0f and maxDigitalZoom inclusive. |
|
var facing: Int
Set which camera to use (like front or back). Supported values are Modes.Facing. |
|
var flash: Int
Set flash mode. Supported values are Modes.Flash. See android.hardware.camera2.CaptureRequest.FLASH_MODE |
|
val isCameraOpened: Boolean
|
|
var jpegQuality: Int
Set image quality of the output image. This property is only applicable for outputFormat Supported values are Modes.JpegQuality. |
|
val maxDigitalZoom: Float
Maximum digital zoom supported by selected camera device. |
|
var noiseReduction: Int
Set noise reduction mode. Supported values are Modes.NoiseReduction. See android.hardware.camera2.CaptureRequest.NOISE_REDUCTION_MODE |
|
var opticalStabilization: Boolean
Turn on or off optical stabilization for preview and still captures. See android.hardware.camera2.CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE |
|
var outputFormat: Int
Set format of the output of image data produced from the camera for Modes.CameraMode.SINGLE_CAPTURE mode. Supported values are Modes.OutputFormat. |
|
var pinchToZoom: Boolean
Allow pinch gesture on camera view for digital zooming. True is on and false is off. |
|
var shutter: Int
Current shutter time in milliseconds. Supported values are Modes.Shutter. |
|
val supportedAspectRatios: Set<AspectRatio>
Gets all the aspect ratios supported by the current camera. |
|
var touchToFocus: Boolean
Allow manual focus on an area by tapping on camera view. True is on and false is off. |
|
var zsl: Boolean
Set zero shutter lag mode capture. See android.hardware.camera2.CameraDevice.TEMPLATE_ZERO_SHUTTER_LAG |
fun addCameraClosedListener(listener: () -> Unit): CameraView
Add a new camera closed listener. |
|
fun addCameraErrorListener(listener: (t: Throwable) -> Unit): CameraView
Add a new camera error listener. If no error listeners are added, then "critical" errors will be thrown to system exception handler (ie. hard crash) The only critical error thrown for now is for invalid aspect ratio. |
|
fun addCameraOpenedListener(listener: () -> Unit): CameraView
Add a new camera opened listener. |
|
fun addPictureTakenListener(listener: (imageData: ByteArray) -> Unit): CameraView
Add a new picture taken listener. |
|
fun capture(): Unit
Take a picture. The result will be returned to listeners added by addPictureTakenListener. |
|
fun onAttachedToWindow(): Unit |
|
fun onDetachedFromWindow(): Unit |
|
fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit |
|
fun onRestoreInstanceState(state: <ERROR CLASS>?): Unit |
|
fun onSaveInstanceState(): <ERROR CLASS>? |
|
fun pauseVideoRecording(): Boolean
Pause video recording |
|
fun removeAllListeners(): Unit
Remove all listeners previously set. |
|
fun removeCameraClosedListener(listener: () -> Unit): CameraView
Remove camera closed listener. |
|
fun removeCameraErrorListener(listener: (Throwable) -> Unit): CameraView
Remove camera error listener. |
|
fun removeCameraOpenedListener(listener: () -> Unit): CameraView
Remove camera opened listener. |
|
fun removePictureTakenListener(listener: (ByteArray) -> Unit): CameraView
Remove picture taken listener. |
|
fun removePreviewFrameListener(): CameraView
Remove preview frame listener. |
|
fun resumeVideoRecording(): Boolean
Resume video recording |
|
fun setPreviewFrameListener(listener: (<ERROR CLASS>) -> Unit): CameraView
Set preview frame listener. Be careful while using this listener as it is invoked on each frame, which could be 60 times per second if frame rate is 60 fps. Ideally, next frame should only be processed once current frame is done processing. Continuously launching background tasks for each frame is is not memory efficient, the device will run out of memory very quickly and force close the app. |
|
fun start(): Unit
Open a camera device and start showing camera preview. This is typically called from Activity.onResume. |
|
fun startVideoRecording(outputFile: File, config: VideoConfiguration.() -> Unit = {}): Unit fun startVideoRecording(outputFile: File, config: <ERROR CLASS>.() -> Unit = {}): Unit
Start capturing video. |
|
fun stop(removeAllListeners: Boolean = false): Unit
Stop camera preview and close the device. This is typically called from Activity.onPause. |
|
fun stopVideoRecording(): Boolean
Stop video recording |