Class ScanbotCameraXView
-
- All Implemented Interfaces:
-
android.graphics.drawable.Drawable.Callback,android.view.KeyEvent.Callback,android.view.ViewManager,android.view.ViewParent,android.view.accessibility.AccessibilityEventSource,io.scanbot.sdk.ui.camera.IScanbotCameraView,io.scanbot.sdk.ui.camera.UiZoomDelegate,io.scanbot.sdk.ui.camera.util.FinderViewAttributeHandler
public final class ScanbotCameraXView extends FrameLayout implements IScanbotCameraView, UiZoomDelegate, FinderViewAttributeHandler
Wrapper view for CameraX.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceScanbotCameraXView.PinchToZoomCallbackPinch to Zoom Callback
-
Field Summary
Fields Modifier and Type Field Description private Array<Size>supportedPreviewSizesprivate Array<Size>supportedPictureSizesprivate ZoomRangesupportedZoomRangeprivate ScanbotCameraXView.PinchToZoomCallbackpinchToZoomListenerprivate <Error class: unknown class>lifecycleOwnerprivate LongdelayAfterFocusCompleteMs
-
Constructor Summary
Constructors Constructor Description ScanbotCameraXView(Context context)ScanbotCameraXView(Context context, AttributeSet attrs)
-
Method Summary
Modifier and Type Method Description final Array<Size>getSupportedPreviewSizes()final UnitsetSupportedPreviewSizes(Array<Size> supportedPreviewSizes)final Array<Size>getSupportedPictureSizes()final UnitsetSupportedPictureSizes(Array<Size> supportedPictureSizes)final ZoomRangegetSupportedZoomRange()final UnitsetSupportedZoomRange(ZoomRange supportedZoomRange)final ScanbotCameraXView.PinchToZoomCallbackgetPinchToZoomListener()final UnitsetPinchToZoomListener(ScanbotCameraXView.PinchToZoomCallback pinchToZoomListener)final <Error class: unknown class>getLifecycleOwner()final Unit)>setLifecycleOwner(<Error class: unknown class> lifecycleOwner)LonggetDelayAfterFocusCompleteMs()Delay that camera will took before snap on auto focus complete called from camera core in ms. UnitsetDelayAfterFocusCompleteMs(Long delayAfterFocusCompleteMs)Delay that camera will took before snap on auto focus complete called from camera core in ms. <T extends FrameHandler> TgetAttachedFrameHandler(Class<T> clazz)Check whether there is same class of FrameHandler attached to the view return object of the same class if exists otherwise null UnitaddFrameHandler(FrameHandler frameHandler)Used to add FrameHandler that will be called on each next frame. UnitremoveFrameHandler(FrameHandler frameHandler)Unregisters FrameHandler. UnitsetPreviewMode(CameraPreviewMode previewMode)Set the camera preview mode. UnittakePicture(Boolean acquireFocus)Takes picture. UnittakePicture(Boolean acquireFocus, Boolean isCapturedAutomatically)Takes picture. UnitaddPictureCallback(BasePictureCallback pictureCallback)Adds callback which will be notified when picture will be taken. UnitremovePictureCallback(BasePictureCallback pictureCallback)Removes callback, so it won't receive any further notifications. UnitsetCameraOpenCallback(CameraOpenCallback cameraOpenCallback)Callback which will be invoked when camera will be opened UnitaddCameraStateCallback(CameraStateCallback cameraStateCallback)Adds callback which will be notified about camera state changes. UnitsetCaptureCallback(CaptureCallback captureCallback)Sets the callback which will be notified about the moment of actual image capture. UnitremoveCameraStateCallback(CameraStateCallback cameraStateCallback)Removes callback, so it won't receive any further notifications. UnitaddTakePictureCallback(CameraTakePictureCallback cameraTakePictureCallback)Adds callback which will be notified about take picture operation process. UnitremoveTakePictureCallback(CameraTakePictureCallback cameraTakePictureCallback)Removes callback, so it won't receive any further notifications. UnitsetAutoFocusOnTouch(Boolean autoFocusOnTouch)UnitautoFocus()Performs auto-focus. UnitcontinuousFocus()Cancels auto-focus and performs continuous-focus. UnituseFlash(Boolean useFlash)Enables or disables camera flash. UnitlockToPortrait(Boolean lockPicture)Locks camera in portrait mode UnitlockToLandscape(Boolean lockPicture)Locks camera in landscape mode UnitunlockOrientation()Unlocks camera orientation UnitusePinchToZoom(Boolean usePinchToZoom)Enables/disables Pinch-to-Zoom camera functionality BooleanisFlashEnabled()Returns the current state of the flashlight Should be executed from the main thread and when camera is opened final UnitisSnapAnimationEnabled(Boolean enabled)UnitstartPreview()Starts/resumes camera preview stream. UnitstopPreview()Stops camera preview stream. final UnitfreezePreview()Stops camera preview stream but leaving detection enabled. final UnitunfreezePreview()Resume camera preview stream after the freeze. UnitrestartPreview()Restarts preview stream. UnitlockMinFocusDistance(Boolean lock)Locks the min supported focus distance and disables continuous focus UnitsetPhysicalZoomRange(ZoomRange zoomRange)Set custom zoom range. UnitsetPhysicalZoom(Float zoom)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. UnitsetCameraModule(CameraModule cameraModule)Defines a camera module. final UnitsetPictureSize(Size pictureSize)Set camera picture size. final UnitsetCameraFrameSize(Size frameSize)Set camera preview and analyzer frame size. final UnitsetPreviewFrameSize(Size frameSize)Set camera preview frame size. final UnitsetPreviewRotation(Integer rotation)Set camera preview frame rotation. final UnitsetAnalyzerFrameSize(Size frameSize)Set camera analyzer frame size. final UnitsetAnalyzerFpsLimit(Float fps)Limit the frame rate of the camera analyzer. final UnitsetAnalyzerEnabled(Boolean enabled)Set whether camera analyzer should be enabled or not. UnitsetForceMaxSnappingSize(Boolean enabled)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 falseThis parameter works only withScanbotCameraXViewenabledUnitsetForceMaxSnappingQuality(Boolean enabled)Set whether camera should force maximum possible quality of snapped picture. UnitsetSnappingAutoAdjustment(Boolean enabled)Set whether camera should automatically adjusts the final image with the surrounding scenery. UnitsetShutterSound(Boolean value)Set camera shutter sound state. UnitsetUiZoomLevel(Float zoomLevel)Passes the zoom value to the dependent view -
-
Constructor Detail
-
ScanbotCameraXView
ScanbotCameraXView(Context context)
-
ScanbotCameraXView
ScanbotCameraXView(Context context, AttributeSet attrs)
-
-
Method Detail
-
getSupportedPreviewSizes
final Array<Size> getSupportedPreviewSizes()
-
setSupportedPreviewSizes
final Unit setSupportedPreviewSizes(Array<Size> supportedPreviewSizes)
-
getSupportedPictureSizes
final Array<Size> getSupportedPictureSizes()
-
setSupportedPictureSizes
final Unit setSupportedPictureSizes(Array<Size> supportedPictureSizes)
-
getSupportedZoomRange
final ZoomRange getSupportedZoomRange()
-
setSupportedZoomRange
final Unit setSupportedZoomRange(ZoomRange supportedZoomRange)
-
getPinchToZoomListener
final ScanbotCameraXView.PinchToZoomCallback getPinchToZoomListener()
-
setPinchToZoomListener
final Unit setPinchToZoomListener(ScanbotCameraXView.PinchToZoomCallback pinchToZoomListener)
-
getLifecycleOwner
final <Error class: unknown class> getLifecycleOwner()
-
setLifecycleOwner
final Unit )>setLifecycleOwner(<Error class: unknown class> lifecycleOwner)
-
getDelayAfterFocusCompleteMs
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.
-
setDelayAfterFocusCompleteMs
Unit setDelayAfterFocusCompleteMs(Long delayAfterFocusCompleteMs)
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.
-
getAttachedFrameHandler
<T extends FrameHandler> T getAttachedFrameHandler(Class<T> clazz)
Check whether there is same class of FrameHandler attached to the view return object of the same class if exists otherwise null
-
addFrameHandler
@Synchronized() Unit addFrameHandler(FrameHandler frameHandler)
Used to add FrameHandler that will be called on each next frame.
-
removeFrameHandler
@Synchronized() Unit removeFrameHandler(FrameHandler frameHandler)
Unregisters FrameHandler.
- Parameters:
frameHandler- handler to unregister.
-
setPreviewMode
Unit setPreviewMode(CameraPreviewMode previewMode)
Set the camera preview mode. By default - CameraPreviewMode.FILL_IN.
- Parameters:
previewMode-camera preview mode
-
takePicture
Unit takePicture(Boolean acquireFocus)
Takes picture.
This is asynchronous process, so results are reported via PictureCallback added in addPictureCallback. If snapping process is still going all subsequent calls to takePicture are ignored.
After picture is taken, camera preview is stopped. If you wish it continue, use startPreview If view is paused, this call is ignored.
- Parameters:
acquireFocus- true to perform auto-focus before shooting.
-
takePicture
Unit takePicture(Boolean acquireFocus, Boolean isCapturedAutomatically)
Takes picture.
This is asynchronous process, so results are reported via PictureCallback added in addPictureCallback. If snapping process is still going all subsequent calls to takePicture are ignored.
After picture is taken, camera preview is stopped. If you wish it continue, use startPreview If view is paused, this call is ignored.
- Parameters:
acquireFocus-trueto perform auto-focus before shooting.isCapturedAutomatically- allows to define if the picture was taken automatically by any of AutoSnappingController.
-
addPictureCallback
Unit addPictureCallback(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.
- Parameters:
pictureCallback- callback to register.
-
removePictureCallback
Unit removePictureCallback(BasePictureCallback pictureCallback)
Removes callback, so it won't receive any further notifications.
- Parameters:
pictureCallback- callback to unregister.
-
setCameraOpenCallback
Unit setCameraOpenCallback(CameraOpenCallback cameraOpenCallback)
Callback which will be invoked when camera will be opened
- Parameters:
cameraOpenCallback- callback
-
addCameraStateCallback
Unit addCameraStateCallback(CameraStateCallback cameraStateCallback)
Adds callback which will be notified about camera state changes. Callbacks are invoked on a main thread.
- Parameters:
cameraStateCallback- callback to register.
-
setCaptureCallback
Unit setCaptureCallback(CaptureCallback captureCallback)
Sets the callback which will be notified about the moment of actual image capture.
- Parameters:
captureCallback- callback to register
-
removeCameraStateCallback
Unit removeCameraStateCallback(CameraStateCallback cameraStateCallback)
Removes callback, so it won't receive any further notifications.
- Parameters:
cameraStateCallback- callback to unregister.
-
addTakePictureCallback
Unit addTakePictureCallback(CameraTakePictureCallback cameraTakePictureCallback)
Adds callback which will be notified about take picture operation process. Callbacks are invoked on a main thread.
- Parameters:
cameraTakePictureCallback- callback to register.
-
removeTakePictureCallback
Unit removeTakePictureCallback(CameraTakePictureCallback cameraTakePictureCallback)
Removes callback, so it won't receive any further notifications.
- Parameters:
cameraTakePictureCallback- callback to unregister.
-
setAutoFocusOnTouch
Unit setAutoFocusOnTouch(Boolean autoFocusOnTouch)
- Parameters:
autoFocusOnTouch- iftrue- auto focus on touch will be enabled,false- otherwise.
-
autoFocus
Unit autoFocus()
Performs auto-focus.
If there is no auto-focus capabilities on this device, does nothing.
If view is paused, this call is ignored.
-
continuousFocus
Unit 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.
-
useFlash
Unit 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.
- Parameters:
useFlash-trueto enable flash.
-
lockToPortrait
Unit lockToPortrait(Boolean lockPicture)
Locks camera in portrait mode
- Parameters:
lockPicture- iftrue- taken picture will ba locked to the portrait orientation,false- picture orientation depends on the device sensor.
-
lockToLandscape
Unit lockToLandscape(Boolean lockPicture)
Locks camera in landscape mode
- Parameters:
lockPicture- iftrue- taken picture will ba locked to the landscape orientation,false- picture orientation depends on the device sensor.
-
unlockOrientation
Unit unlockOrientation()
Unlocks camera orientation
-
usePinchToZoom
Unit usePinchToZoom(Boolean usePinchToZoom)
Enables/disables Pinch-to-Zoom camera functionality
- Parameters:
usePinchToZoom-trueif Pinch-to-Zoom should be enabled,false- otherwise
-
isFlashEnabled
Boolean isFlashEnabled()
Returns the current state of the flashlight Should be executed from the main thread and when camera is opened
-
isSnapAnimationEnabled
final Unit isSnapAnimationEnabled(Boolean enabled)
-
startPreview
Unit startPreview()
Starts/resumes camera preview stream. Usually used after picture was taken. Note, the preview is started by default only once after the view is attached, so it's required to call it if the preview was stopped and the view was not reattached.
-
stopPreview
Unit stopPreview()
Stops camera preview stream.
-
freezePreview
final Unit freezePreview()
Stops camera preview stream but leaving detection enabled. Internal Use Only!
-
unfreezePreview
final Unit unfreezePreview()
Resume camera preview stream after the freeze. Internal Use Only!
-
restartPreview
Unit restartPreview()
Restarts preview stream.
-
lockMinFocusDistance
Unit lockMinFocusDistance(Boolean lock)
Locks the min supported focus distance and disables continuous focus
- Parameters:
lock- iftrueminimal available focus distance will be locked,false- otherwise Default isfalse.
-
setPhysicalZoomRange
Unit setPhysicalZoomRange(ZoomRange zoomRange)
Set custom zoom range. Default value is ZoomRange(0.5f, 100f).
- Parameters:
zoomRange- Target zoom range
-
setPhysicalZoom
Unit setPhysicalZoom(Float zoom)
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.
- Parameters:
zoom- Target zoom level
-
setCameraModule
Unit setCameraModule(CameraModule cameraModule)
Defines a camera module. By default is CameraModule.BACK.
- Parameters:
cameraModule- CameraModule to use.
-
setPictureSize
final Unit setPictureSize(Size pictureSize)
Set camera picture size. Make sure to set the size with the correct orientation.
-
setCameraFrameSize
final Unit setCameraFrameSize(Size frameSize)
Set camera preview and analyzer frame size. Make sure to set the size with the correct orientation.
-
setPreviewFrameSize
final Unit setPreviewFrameSize(Size frameSize)
Set camera preview frame size. Make sure to set the size with the correct orientation.
-
setPreviewRotation
final Unit setPreviewRotation(Integer rotation)
Set camera preview frame rotation. Rotation is one of four valid values: Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, Surface.ROTATION_270. Rotation values are relative to the "natural" rotation, Surface.ROTATION_0. By default, the camera preview frame rotation is same as display rotation.
-
setAnalyzerFrameSize
final Unit setAnalyzerFrameSize(Size frameSize)
Set camera analyzer frame size. Make sure to set the size with the correct orientation.
-
setAnalyzerFpsLimit
final Unit setAnalyzerFpsLimit(Float fps)
Limit the frame rate of the camera analyzer. By default, the frame rate is set to the maximum possible value.
-
setAnalyzerEnabled
final Unit setAnalyzerEnabled(Boolean enabled)
Set whether camera analyzer should be enabled or not. By default, the analyzer is enabled.
-
setForceMaxSnappingSize
Unit setForceMaxSnappingSize(Boolean enabled)
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
falseThis parameter works only withScanbotCameraXViewenabled
-
setForceMaxSnappingQuality
Unit setForceMaxSnappingQuality(Boolean enabled)
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
falseThis parameter works only withScanbotCameraXViewenabled
-
setSnappingAutoAdjustment
Unit setSnappingAutoAdjustment(Boolean enabled)
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.
-
setShutterSound
Unit setShutterSound(Boolean value)
Set camera shutter sound state.
trueif 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.Note that devices may not always allow disabling the camera shutter sound. If the shutter sound state cannot be set to the desired value, this method will be ignored.
-
setUiZoomLevel
Unit setUiZoomLevel(Float zoomLevel)
Passes the zoom value to the dependent view
- Parameters:
zoomLevel- the new scale of the UI
-
-
-
-