Class CameraConfig
-
- All Implemented Interfaces:
public class CameraConfig
Class to specify desired settings and to hold the actual used settings for the camera. (API independent)
-
-
Constructor Summary
Constructors Constructor Description CameraConfig()
New instance with a default configuration for the camera.
-
Method Summary
Modifier and Type Method Description void
updateScale(int newWidth, int newHeight)
CameraSize
getFrameSize()
int
getFrameWidth()
int
getFrameHeight()
float
getFrameToViewScale()
float
getFrameToViewScaleWidth()
CameraSize
getPreviewSize()
void
setPreviewSize(@Nullable() CameraSize previewSize)
Set the preview size that should be used by the camera CameraSize
getPictureSize()
void
setPictureSize(@Nullable() CameraSize pictureSize)
Set the picture size that should be used by the camera CameraSize
getHighResolutionImageSize()
void
setHighResolutionPictureSize(@Nullable() CameraSize highResImageSize)
Set the size for high resolution images that should be used by the camera CameraFeatures.FocusMode
getFocusMode()
void
setFocusMode(@Nullable() CameraFeatures.FocusMode focusMode)
Set the focus mode boolean
isFocusModeAuto()
CameraFeatures.SceneMode
getSceneMode()
void
setSceneMode(@NonNull() CameraFeatures.SceneMode sceneMode)
Set the scene mode that should be used. boolean
isFocusRegionEnabled()
void
setFocusRegionEnabled(boolean focusRegionEnabled)
Set to true to use the region where the cutout is for focusing. boolean
isAutoExposureRegionEnabled()
void
setAutoExposureRegionEnabled(boolean autoExposureRegionEnabled)
Set to true to use the region where the cutout is for auto exposure calculation. boolean
isFocusOnTouchEnabled()
void
setFocusOnTouchEnabled(boolean focusOnTouchEnabled)
Set to true if focus on touch should be enabled (only relevant if focus mode is auto or macro) boolean
isUpdateRegionsOnAutoFocusEnabled()
void
setUpdateRegionsOnAutoFocusEnabled(boolean updateRegionsOnAutoFocusEnabled)
Set to true if regions should be changed slightly before every auto focus call. boolean
isVideoStabilizationEnabled()
void
setVideoStabilizationEnabled(boolean videoStabilizationEnabled)
Set if software video stabilization should be used. int
getAutoFocusInterval()
void
setAutoFocusInterval(int autoFocusInterval)
Set the interval in millis the auto focus should be called in (or <= 0 if it should not be used). boolean
isZoomGestureEnabled()
Get boolean if zoom gesture is enabled void
setZoomGestureEnabled(boolean zoomGestureEnabled)
Enable the Gesture for pinch to zoom double
getFocalLength()
Get the current focal length void
setFocalLength(double focalLength)
Set a focal length to the camera double
getZoomRatio()
Get the current zoom ratio void
setZoomRatio(double zoomRatio)
Set a zoom Ratio to the camera double
getMaxFocalLength()
Get the naximum focal length void
setMaxFocalLength(double maxFocalLength)
Set a custom maximum focal Length double
getMaxZoomRatio()
Get boolean if zoom gesture is enabled void
setMaxZoomRatio(double maxZoomRatio)
Set a custom maximum zoom Ratio CameraFeatures.LensFacing
getLensFacing()
void
setLensFacing(CameraFeatures.LensFacing lensFacing)
Set the default camera used for scanning EnumSet<CameraFeatures.LensFacing>
getFallbackLensFacings()
void
setFallbackLensFacings(Array<CameraFeatures.LensFacing> fallbackLensFacings)
Set the fallback camera facings which are used if the default camera facing is not available on the device void
setFallbackLensFacings(EnumSet<CameraFeatures.LensFacing> fallbackLensFacings)
Set the fallback camera facings which are used if the default camera facing is not available on the device String
toString()
-
-
Method Detail
-
updateScale
void updateScale(int newWidth, int newHeight)
-
getFrameSize
CameraSize getFrameSize()
- Returns:
the size of the preview frame (pixels of the full preview image)
-
getFrameWidth
int getFrameWidth()
- Returns:
the preview frame width in pixels
-
getFrameHeight
int getFrameHeight()
- Returns:
the preview frame height in pixels
-
getFrameToViewScale
float getFrameToViewScale()
- Returns:
the scale factor (scale * frame size = view size)
-
getFrameToViewScaleWidth
float getFrameToViewScaleWidth()
-
getPreviewSize
CameraSize getPreviewSize()
- Returns:
the preview size to use for the camera (may be in landscape)
-
setPreviewSize
void setPreviewSize(@Nullable() CameraSize previewSize)
Set the preview size that should be used by the camera
- Parameters:
previewSize
- the desired preview size
-
getPictureSize
@Nullable()@Deprecated() CameraSize getPictureSize()
- Returns:
the picture size to use for the camera (may be in landscape)
-
setPictureSize
@Deprecated() void setPictureSize(@Nullable() CameraSize pictureSize)
Set the picture size that should be used by the camera
- Parameters:
pictureSize
- the desired picture size
-
getHighResolutionImageSize
@Nullable() CameraSize getHighResolutionImageSize()
- Returns:
the size for high resolution images to use for the camera (may be in landscape)
-
setHighResolutionPictureSize
void setHighResolutionPictureSize(@Nullable() CameraSize highResImageSize)
Set the size for high resolution images that should be used by the camera
- Parameters:
highResImageSize
- the desired picture size
-
getFocusMode
@Nullable() CameraFeatures.FocusMode getFocusMode()
- Returns:
the focus mode
-
setFocusMode
void setFocusMode(@Nullable() CameraFeatures.FocusMode focusMode)
Set the focus mode
- Parameters:
focusMode
- the focus mode
-
isFocusModeAuto
boolean isFocusModeAuto()
- Returns:
true if the focus mode of this settings is a mode that requires manual autofocus calls (auto or macro)
-
getSceneMode
@NonNull() CameraFeatures.SceneMode getSceneMode()
- Returns:
the scene mode
-
setSceneMode
void setSceneMode(@NonNull() CameraFeatures.SceneMode sceneMode)
Set the scene mode that should be used.
WARNING: Scene mode behavior is device dependent and it may overrule all the other focus and auto exposure settings. Usage NOT recommended.
- Parameters:
sceneMode
- the scene mode to use (if available)
-
isFocusRegionEnabled
boolean isFocusRegionEnabled()
- Returns:
true if focus region is enabled
-
setFocusRegionEnabled
void setFocusRegionEnabled(boolean focusRegionEnabled)
Set to true to use the region where the cutout is for focusing.
- Parameters:
focusRegionEnabled
- true to enable
-
isAutoExposureRegionEnabled
boolean isAutoExposureRegionEnabled()
- Returns:
true if auto exposure region is enabled
-
setAutoExposureRegionEnabled
void setAutoExposureRegionEnabled(boolean autoExposureRegionEnabled)
Set to true to use the region where the cutout is for auto exposure calculation.
- Parameters:
autoExposureRegionEnabled
- true to enable
-
isFocusOnTouchEnabled
boolean isFocusOnTouchEnabled()
- Returns:
true if focus on touch is enabled (only relevant if focus mode is auto or macro)
-
setFocusOnTouchEnabled
void setFocusOnTouchEnabled(boolean focusOnTouchEnabled)
Set to true if focus on touch should be enabled (only relevant if focus mode is auto or macro)
- Parameters:
focusOnTouchEnabled
- true to enable
-
isUpdateRegionsOnAutoFocusEnabled
boolean isUpdateRegionsOnAutoFocusEnabled()
- Returns:
true if regions should be changed slightly before every auto focus call
-
setUpdateRegionsOnAutoFocusEnabled
void setUpdateRegionsOnAutoFocusEnabled(boolean updateRegionsOnAutoFocusEnabled)
Set to true if regions should be changed slightly before every auto focus call. Only relevant if isFocusModeAuto and isFocusRegionEnabled. (Some devices require slight change in the region or they don't work).
- Parameters:
updateRegionsOnAutoFocusEnabled
- true to enable
-
isVideoStabilizationEnabled
boolean isVideoStabilizationEnabled()
- Returns:
true if software video stabilization should be used
-
setVideoStabilizationEnabled
void setVideoStabilizationEnabled(boolean videoStabilizationEnabled)
Set if software video stabilization should be used.
Note: this will be ignored if optical stabilization is also enabled and available (they are mutually exclusive and optical should be better)
- Parameters:
videoStabilizationEnabled
- true if software video stabilization should be used
-
getAutoFocusInterval
int getAutoFocusInterval()
- Returns:
the interval in millis the auto focus should be called in (or <= 0 if not used)
-
setAutoFocusInterval
void setAutoFocusInterval(int autoFocusInterval)
Set the interval in millis the auto focus should be called in (or <= 0 if it should not be used). This will only have an effect if the focus mode is AUTO or MACRO. (Minimum step size is 500ms).
- Parameters:
autoFocusInterval
- the interval in milliseconds
-
isZoomGestureEnabled
boolean isZoomGestureEnabled()
Get boolean if zoom gesture is enabled
- Returns:
zoomGestureEnabled
-
setZoomGestureEnabled
void setZoomGestureEnabled(boolean zoomGestureEnabled)
Enable the Gesture for pinch to zoom
-
getFocalLength
double getFocalLength()
Get the current focal length
- Returns:
focalLength
-
setFocalLength
void setFocalLength(double focalLength)
Set a focal length to the camera
-
getZoomRatio
double getZoomRatio()
Get the current zoom ratio
- Returns:
zoomRatio
-
setZoomRatio
void setZoomRatio(double zoomRatio)
Set a zoom Ratio to the camera
-
getMaxFocalLength
double getMaxFocalLength()
Get the naximum focal length
- Returns:
zoomGestureEnabled
-
setMaxFocalLength
void setMaxFocalLength(double maxFocalLength)
Set a custom maximum focal Length
-
getMaxZoomRatio
double getMaxZoomRatio()
Get boolean if zoom gesture is enabled
- Returns:
zoomGestureEnabled
-
setMaxZoomRatio
void setMaxZoomRatio(double maxZoomRatio)
Set a custom maximum zoom Ratio
-
getLensFacing
CameraFeatures.LensFacing getLensFacing()
- Returns:
the default camera to use for scanning
-
setLensFacing
void setLensFacing(CameraFeatures.LensFacing lensFacing)
Set the default camera used for scanning
- Parameters:
lensFacing
- the CameraFacing
-
getFallbackLensFacings
EnumSet<CameraFeatures.LensFacing> getFallbackLensFacings()
- Returns:
the fallback CameraFacings
-
setFallbackLensFacings
void setFallbackLensFacings(Array<CameraFeatures.LensFacing> fallbackLensFacings)
Set the fallback camera facings which are used if the default camera facing is not available on the device
- Parameters:
fallbackLensFacings
- the fallback options for CameraFacing
-
setFallbackLensFacings
void setFallbackLensFacings(EnumSet<CameraFeatures.LensFacing> fallbackLensFacings)
Set the fallback camera facings which are used if the default camera facing is not available on the device
- Parameters:
fallbackLensFacings
- the fallback options for CameraFacing
-
-
-
-