public class ScanbotCameraXView implements IScanbotCameraView, UiZoomDelegate, FinderViewAttributeHandler
Wrapper view for CameraX
public static io.scanbot.sdk.ui.camera.ScanbotCameraXView.Companion Companion
public ScanbotCameraXView(@NotNull
android.content.Context context,
@NotNull
android.util.AttributeSet attrs)
Wrapper view for CameraX
@NotNull public android.util.Size[] getSupportedPreviewSizes()
public void setSupportedPreviewSizes(@NotNull
android.util.Size[] p)
@NotNull public android.util.Size[] getSupportedPictureSizes()
public void setSupportedPictureSizes(@NotNull
android.util.Size[] p)
@Nullable public androidx.lifecycle.LifecycleOwner getLifecycleOwner()
public void setLifecycleOwner(@Nullable
androidx.lifecycle.LifecycleOwner p)
public long getDelayAfterFocusCompleteMs()
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.
public void setDelayAfterFocusCompleteMs(long p)
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.
protected void onAttachedToWindow()
protected void onDetachedFromWindow()
@Nullable public <T extends FrameHandler> T getAttachedFrameHandler(@NotNull java.lang.Class<T> clazz)
Check whether there is same class of interface FrameHandler attached to the view
return object of the same class if exists otherwise null
interface FrameHandler,
nullpublic void addFrameHandler(@NotNull
FrameHandler frameHandler)
Used to add frame handler that will be called on each next frame
public void removeFrameHandler(@NotNull
FrameHandler frameHandler)
Unregisters interface FrameHandler.
frameHandler - handler to unregister. If it was not registered before, nothing happens.interface FrameHandlerpublic void setPreviewMode(@NotNull
CameraPreviewMode previewMode)
Set the camera preview mode. By default - CameraPreviewMode.FILL_IN.
previewMode - camera preview mode
public void takePicture(boolean acquireFocus)
Takes picture.
acquireFocus - {@code true} to perform auto-focus before shooting. {@code false} to shoot as fast as possible using current camera state.public void addPictureCallback(@NotNull
BasePictureCallback pictureCallback)
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.
pictureCallback - callback to register. Must not be null. If this callbackwas already added, nothing happens.class PictureCallbackpublic void removePictureCallback(@NotNull
BasePictureCallback pictureCallback)
Removes callback, so it won't receive any further notifications.
pictureCallback - callback to unregister. If it was not registered before, nothinghappens.public void setCameraOpenCallback(@NotNull
CameraOpenCallback cameraOpenCallback)
Callback which will be invoked when camera will be opened
cameraOpenCallback - callbackpublic void addCameraStateCallback(@NotNull
CameraStateCallback cameraStateCallback)
Adds callback which will be notified about camera state changes. Callbacks are invoked on a main thread.
cameraStateCallback - callback to register. Must not be null. If this callbackwas already added, nothing happens.public void removeCameraStateCallback(@NotNull
CameraStateCallback cameraStateCallback)
Removes callback, so it won't receive any further notifications.
cameraStateCallback - callback to unregister. If it was not registered before, nothinghappens.public void addTakePictureCallback(@NotNull
CameraTakePictureCallback cameraTakePictureCallback)
Adds callback which will be notified about take picture operation process. Callbacks are invoked on a main thread.
cameraTakePictureCallback - callback to register. Must not be null. If this callbackwas already added, nothing happens.public void removeTakePictureCallback(@NotNull
CameraTakePictureCallback cameraTakePictureCallback)
Removes callback, so it won't receive any further notifications.
cameraTakePictureCallback - callback to unregister. If it was not registered before, nothinghappens.public void setAutoFocusOnTouch(boolean autoFocusOnTouch)
autoFocusOnTouch - if true - auto focus on touch will be enabled, false - otherwise.By default this feature is enabled.public void autoFocus()
Performs auto-focus.
If there is no auto-focus capabilities on this device, does nothing.
If view is paused, this call is ignored.
public void continuousFocus()
Cancels auto-focus and performs continuous-focus. Should be executed from the main thread and when camera is opened
If there is no continuous-focus capabilities on this device, does auto-focus.
If view is paused, this call is ignored.
public void useFlash(boolean useFlash)
Enables or disables camera flash.
If there is no flash on this device, does nothing.
If view is paused, this call is ignored.
useFlash - true to enable flash. false to disable flash.public void lockToPortrait(boolean lockPicture)
Locks camera in portrait mode
lockPicture - if true - taken picture will ba locked to the portrait orientation,false - picture orientation depends on the device sensor.public void lockToLandscape(boolean lockPicture)
Locks camera in landscape mode
lockPicture - if true - taken picture will ba locked to the landscape orientation,false - picture orientation depends on the device sensor.public void unlockOrientation()
Unlocks camera orientation
public void usePinchToZoom(boolean usePinchToZoom)
Enables/disables Pinch-to-Zoom camera functionality
usePinchToZoom - true if Pinch-to-Zoom should be enabled, false - otherwisepublic void setOpticalZoomLevel(float zoomLevel)
Sets current zoom by a linear zoom value ranging from 0f to 1.0f. Zoom Level 0f represents the minimum zoom while Zoom Level 1.0f represents the maximum zoom. Default value is 0f.
zoomLevel - Target zoom levelpublic void setOpticalZoomRange(@NotNull
ZoomRange zoomRange)
Set custom zoom range. Default value is ZoomRange0f,1f.
zoomRange - Target zoom rangepublic void setCameraModule(@NotNull
CameraModule cameraModule)
Defines a camera module. By default is CameraModule.BACK.
cameraModule - enum CameraModule to use.public void setPictureSize(@NotNull
android.util.Size pictureSize)
Set camera picture size
pictureSize - public void setPreviewSize(@NotNull
android.util.Size previewSize)
Set camera preview size
previewSize - protected void dispatchDraw(@NotNull
android.graphics.Canvas canvas)
public void setUiZoomLevel(float zoomLevel)
Passes the zoom value to the dependent view
zoomLevel - the new scale of the UIpublic int getFinderViewId()
Default is R.id.finder_overlay