ScanbotCameraView

Provides interface to native Camera and displays camera stream. Use this class if you want to fine-tune camera behavior.

It is required to pass android.app.Activity (or android.app.Fragment) lifecycle events to this view: .onResume, .onPause. They are used to automatically start and stop camera.

It is possible to include other views inside of ScanbotCameraView. In such case they will be drawn on top of camera preview with size matching the camera frame. You can use this fact to draw overlays on top of camera.

Preview frames are provided via PreviewBuffer: .getPreviewBuffer.

Constructors

Link copied to clipboard
constructor(context: Context)
constructor(context: Context, attrs: AttributeSet?)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override var delayAfterFocusCompleteMs: Long

Delay that camera will took before snap on auto focus complete called from camera core in ms. For some devices this callback could call even before real auto focus completed, so we need to take some delay before snapping. Usually you can set 500ms. By default it is set to 20ms.

Link copied to clipboard
open override var lifecycleOwner: <Error class: unknown class>?

Sets lifecycle owner for camera view. N/A for ScanbotCameraView implementation. Setting null means view will attempt to resolve lifecycle on its own.

Link copied to clipboard

TODO: desperately needs documentation!!!

Link copied to clipboard
Link copied to clipboard
open override var supportedZoomRange: ZoomRange

TODO: desperately needs documentation!!!

Functions

Link copied to clipboard
open override fun addCameraStateCallback(cameraStateCallback: CameraStateCallback)

Adds callback which will be notified about camera state changes. Callbacks are invoked on a main thread.

Link copied to clipboard
open override fun addFrameHandler(frameHandler: FrameHandler)

Used to add FrameHandler that will be called on each next frame.

Link copied to clipboard
open override fun addPictureCallback(pictureCallback: BasePictureCallback)

Adds callback which will be notified when picture will be taken. Callbacks are invoked on a worker thread, so you can safely perform "heavy" operations here.

Link copied to clipboard
open override fun addTakePictureCallback(cameraTakePictureCallback: CameraTakePictureCallback)

Adds callback which will be notified about take picture operation process. Callbacks are invoked on a main thread.

Link copied to clipboard
open override fun autoFocus()

Performs auto-focus.

Link copied to clipboard
open override fun continuousFocus()

Cancels auto-focus and performs continuous-focus. Should be executed from the main thread and when camera is opened

Link copied to clipboard
open override fun <T : FrameHandler> getAttachedFrameHandler(clazz: Class<T>): T?

Obtain FrameHandler instance of type clazz, that is attached to the view (if any).

Link copied to clipboard
open override fun isFlashEnabled(): Boolean

Returns the current state of the flashlight Should be executed from the main thread and when camera is opened

Link copied to clipboard
open override fun isSnapAnimationEnabled(enabled: Boolean)

Set whether camera should use snapping animation. By default set to true This parameter works only with ScanbotCameraXView enabled

Link copied to clipboard
open override fun lockMinFocusDistance(lock: Boolean)

Locks the min supported focus distance and disables continuous focus

Link copied to clipboard
open override fun lockToLandscape(lockPicture: Boolean)

Locks camera in landscape mode

Link copied to clipboard
open override fun lockToPortrait(lockPicture: Boolean)

Locks camera in portrait mode

Link copied to clipboard
fun onPause()

Notifies view that enclosing android.app.Activity or android.app.Fragment was paused and therefore camera must be closed.

Link copied to clipboard
fun onResume()

Notifies view that enclosing android.app.Activity or android.app.Fragment was resumed and therefore camera can be started.

Link copied to clipboard
open override fun removeCameraStateCallback(cameraStateCallback: CameraStateCallback)

Removes callback, so it won't receive any further notifications.

Link copied to clipboard
open override fun removeFrameHandler(frameHandler: FrameHandler)

Unregisters given FrameHandler instance.

Link copied to clipboard
open override fun removePictureCallback(pictureCallback: BasePictureCallback)

Removes callback, so it won't receive any further notifications.

Link copied to clipboard
open override fun removeTakePictureCallback(cameraTakePictureCallback: CameraTakePictureCallback)

Removes callback, so it won't receive any further notifications.

Link copied to clipboard
open override fun restartPreview()

Restarts preview stream.

Link copied to clipboard
open override fun setAnalyzerFpsLimit(fps: Float)

Limit the frame rate of the camera analyzer. By default, the frame rate is set to the maximum possible value.

Link copied to clipboard
open override fun setAutoFocusOnTouch(autoFocusOnTouch: Boolean)
Link copied to clipboard

Set camera auto focus sound state. true if system sound should be played on successful auto focus event, false - otherwise. By default, the camera plays the system-defined camera auto focus sound when autoFocus() is called.

Link copied to clipboard
open override fun setCameraModule(cameraModule: CameraModule)

Defines a camera module. By default is CameraModule.BACK.

Link copied to clipboard
open override fun setCameraOpenCallback(cameraOpenCallback: CameraOpenCallback)

Callback which will be invoked when camera will be opened

Link copied to clipboard
open override fun setCaptureCallback(captureCallback: CaptureCallback?)

Sets the callback which will be notified about the moment of actual image capture.

Link copied to clipboard
open override fun setForceMaxSnappingQuality(enabled: Boolean)

Set whether camera should force maximum possible quality of snapped picture. As a result snapping speed could be significantly slower and result image could be bigger. By default set to false This parameter works only with ScanbotCameraXView enabled

Link copied to clipboard
open override fun setForceMaxSnappingSize(enabled: Boolean)

Set whether camera should force maximum possible size of snapped picture or use maximum size that available with the same aspect ratio as preview by default set to false This parameter works only with ScanbotCameraXView enabled

Link copied to clipboard
open override fun setPhysicalZoom(zoomLevel: Float)

Allows to set camera physical zoom value, if the value out of range of real camera min and max values it chooses min or max value. Example: camera physical zoom range 1f..5f if we set 6f it will set 5f. Default value is 1f.

Link copied to clipboard
open override fun setPhysicalZoomRange(zoomRange: ZoomRange)

Set custom zoom range. Default value is ZoomRange(0.5f, 100f).

Link copied to clipboard
fun setPictureSize(pictureSize: Camera.Size)

Set camera picture size

Link copied to clipboard
open override fun setPreviewMode(mode: CameraPreviewMode)

Set the camera preview mode. By default - CameraPreviewMode.FILL_IN.

Link copied to clipboard
fun setPreviewSize(previewSize: Camera.Size)

Set camera preview size

Link copied to clipboard
open override fun setShutterSound(enabled: Boolean)

Set camera shutter sound state. true if system sound should be played on the take picture event, false - otherwise. By default, the camera plays the system-defined camera shutter sound when takePicture() is called.

Link copied to clipboard
open override fun setSnappingAutoAdjustment(enabled: Boolean)

Set whether camera should automatically adjusts the final image with the surrounding scenery. For example, the vendor library implementation might do low-light detection and switch to low-light mode or HDR to take the picture. Alternatively, the face retouch mode could be automatically applied when taking a portrait image. This delegates modes to the vendor library implementation to decide.

Link copied to clipboard
open override fun setUiZoomLevel(zoomLevel: Float)

Passes the zoom value to the dependent view

Link copied to clipboard
open override fun startPreview()

Starts/resumes camera preview stream. Usually used after picture was taken. Note, the preview is started by default after .onResume, so there is no need to call it at the start of the app.

Link copied to clipboard
open override fun stopPreview()

Stops camera preview stream.

Link copied to clipboard
open override fun takePicture(acquireFocus: Boolean)
open override fun takePicture(acquireFocus: Boolean, isCapturedAutomatically: Boolean)

Takes picture.

Link copied to clipboard
open override fun unlockOrientation()

Unlocks camera orientation

Link copied to clipboard
open override fun useFlash(useFlash: Boolean)

Enables or disables camera flash.

Link copied to clipboard
open override fun usePinchToZoom(usePinchToZoom: Boolean)

Enables/disables Pinch-to-Zoom camera functionality