public class 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: , ScanbotCameraView.onResume. They are used to automatically start and stop camera. ScanbotCameraView.onPause
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. In particular, you can use net.doo.snap.ui.PolygonView.
Preview frames are provided via PreviewBuffer: .ScanbotCameraView.getPreviewBuffer
| Constructor and Description |
|---|
ScanbotCameraView() |
ScanbotCameraView() |
| Modifier and Type | Method and Description |
|---|---|
void |
addPictureCallback()
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.
|
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.
|
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.
|
PreviewBuffer |
getPreviewBuffer() |
java.util.List<android.hardware.Camera.Size> |
getSupportedPictureSizes() |
java.util.List<android.hardware.Camera.Size> |
getSupportedPreviewSizes() |
void |
lockToLandscape()
Locks camera in landscape mode
|
void |
lockToPortrait()
Locks camera in portrait mode
|
void |
onLayout() |
void |
onMeasure() |
void |
onPause()
Notifies view that enclosing android.app.Activity or android.app.Fragment was paused and therefore camera must be closed.
|
void |
onResume()
Notifies view that enclosing android.app.Activity or android.app.Fragment was resumed and therefore camera can be started.
|
void |
removePictureCallback()
Removes callback, so it won't receive any further notifications.
|
void |
setAutoFocusOnTouch() |
void |
setAutoFocusSound()
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. |
void |
setCameraOpenCallback()
Callback which will be invoked when camera will be opened
|
void |
setOrientationHardLock()
Sets orientation hard lock mode.
|
void |
setPictureSize()
Set camera picture size
|
void |
setPreviewMode()
Set the camera preview mode. By default -
CameraPreviewMode#FILL_IN. |
void |
setPreviewSize()
Set camera preview size
|
void |
setShutterSound()
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. 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. |
void |
startPreview()
Starts/resumes camera preview stream. Usually used after picture was taken. Note, that preview is started by default after
, so there is no need to call it at the start of the app. If view is paused, this call is ignored. |
void |
stopPreview()
Stops camera preview stream.
|
void |
takePicture()
Takes picture. This is asynchronous process, so results are reported via PictureCallback added in
. If snapping process is still going all subsequent calls to are ignored. After picture is taken, camera preview is stopped. If you wish it continue, use If view is paused, this call is ignored. |
void |
unlockOrientation()
Unlocks camera orientation
|
void |
useFlash()
Enables or disables camera flash. If there is no flash on this device, does nothing. If view is paused, this call is ignored.
|
public ScanbotCameraView()
public ScanbotCameraView()
public void onMeasure()
public void onLayout()
public PreviewBuffer getPreviewBuffer()
public void onResume()
Notifies view that enclosing android.app.Activity or android.app.Fragment was resumed and therefore camera can be started.
public void onPause()
Notifies view that enclosing android.app.Activity or android.app.Fragment was paused and therefore camera must be closed.
public void startPreview()
Starts/resumes camera preview stream. Usually used after picture was taken. Note, that preview is started by default after , so there is no need to call it at the start of the app. ScanbotCameraView.onResume
If view is paused, this call is ignored.
ScanbotCameraView.onResumepublic void stopPreview()
Stops camera preview stream.
public void takePicture()
Takes picture.
This is asynchronous process, so results are reported via PictureCallback added in . If snapping process is still going all subsequent calls to ScanbotCameraView.addPictureCallback are ignored. ScanbotCameraView.takePicture
After picture is taken, camera preview is stopped. If you wish it continue, use ScanbotCameraView.startPreview
If view is paused, this call is ignored.
public void useFlash()
Enables or disables camera flash.
If there is no flash on this device, does nothing.
If view is paused, this call is ignored.
public void setAutoFocusOnTouch()
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 addPictureCallback()
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.
public void removePictureCallback()
Removes callback, so it won't receive any further notifications.
public void setCameraOpenCallback()
Callback which will be invoked when camera will be opened
public java.util.List<android.hardware.Camera.Size> getSupportedPictureSizes()
public java.util.List<android.hardware.Camera.Size> getSupportedPreviewSizes()
public void setPictureSize()
Set camera picture size
public void setPreviewSize()
Set camera preview size
public void setAutoFocusSound()
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.
public void setShutterSound()
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. 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.
public void setPreviewMode()
Set the camera preview mode. By default - CameraPreviewMode#FILL_IN.
public void lockToPortrait()
Locks camera in portrait mode
public void lockToLandscape()
Locks camera in landscape mode
public void setOrientationHardLock()
Sets orientation hard lock mode.
public void unlockOrientation()
Unlocks camera orientation