Class CameraController1
-
- All Implemented Interfaces:
public class CameraController1 extends CameraController
Camera controller implementation for camera API 1
-
-
Field Summary
Fields Modifier and Type Field Description public Cameracamerapublic CameraFeatures.LensFacingcameraLensFacingpublic intmaxZoomLevelpublic doublezoomRatio
-
Method Summary
Modifier and Type Method Description CameragetCamera()CameraFeatures.LensFacinggetCameraLensFacing()intgetMaxZoomLevel()doublegetZoomRatio()Get the current zoom ratio voidsetZoomRatio(double zoomLevelRatio)Set a zoom level through zoom Ratio voidreleaseCameraAndPreview()Release the camera for the landscape to landscape mode. booleanhasNewImage()AnylineYuvImagegetNewImage()AnylineImagegetLastImageWithFullSize()Get the latest image in full size. ImageReceivergetLastImageWithFullSizeReceiver()Get the a receiver for the latest image in full size. AnylineImagegetHighResolutionImage()voidtakeHighResolutionImage()Takes a picture from the camera and calls onImageTaken after the image is taken successfully. voidtakeHighResolutionImage(int top, int left, int right, int bottom, int scanViewWidth, int scanViewHeight)voidsetFlashOn(boolean isOn)Turn the torch flash on or off. voidsetupZoomHandler(View view)Set up the zoom for the camera voidsetCustomZoomLevel(int zoomLevel)voidsetMaxZoomRatio(double maxZoomRatio)Set a maximum zoom ratio voidsetMaxFocalLength(double maxFocalLength)Set a maximum focal length voidsetMinCameraExposure()set the minimum camera exposure voidsetExposureForBlackOnBlack()voidsetDefaultCameraExposure()set default camera exposure intgetMinCameraExposure()intgetMaxCameraExposure()doublegetCurrentFocalLength()Get the current focal length voidcallAutoFocus()Call auto focus. voidopenCameraInBackground()Open the camera in a background thread, if surface is already created and camera is not opened already. booleanopenCameraInBackgroundSuccessfully()voidreleaseCameraInBackground()Release the camera in a background thread. CameraController.CameraOrientationgetCameraOrientation()voidsetCameraOrientation(CameraController.CameraOrientation cameraOrientation)Allows you to set the camera orientation for the BACK camera. voidreleaseCamera()Release the camera. voidresetPreviewCallback()Reset the preview callback. voidsetFocusRegionToCutout(@NonNull() Context context, @NonNull() RectF cutOutRect, float surfaceWidth, float surfaceHeight)Updates the focus and metering region to be the same as the given cutout. voidsetFocalLength(double focalLength)Set a zoom level through focal length -
Methods inherited from class io.anyline2.camera.CameraController
getCameraConfig, getCameraFeatures, getFocalLength, getFrameHeight, getFrameToViewScale, getFrameToViewScaleWidth, getFrameWidth, getPreferredCameraConfig, getPreviewView, isPreviewMirrored, removeAllCameraOpenListeners, removeCameraOpenListener, resetAutoFocusTimer, setCameraControllerListener, setCameraOpenListener, setFocusRegionToCutouts, setHighResolutionImageListener, setImageListener, setPreferredCameraConfig, setZoomGestureEnabled -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getCameraLensFacing
CameraFeatures.LensFacing getCameraLensFacing()
-
getMaxZoomLevel
int getMaxZoomLevel()
-
getZoomRatio
double getZoomRatio()
Get the current zoom ratio
-
setZoomRatio
void setZoomRatio(double zoomLevelRatio)
Set a zoom level through zoom Ratio
-
releaseCameraAndPreview
void releaseCameraAndPreview()
Release the camera for the landscape to landscape mode.
-
hasNewImage
boolean hasNewImage()
- Returns:
true if a new image is available in the buffer
-
getNewImage
AnylineYuvImage getNewImage()
- Returns:
the next new image (sets hasNewImage to false until another image is available)
-
getLastImageWithFullSize
AnylineImage getLastImageWithFullSize()
Get the latest image in full size. This does not check or manipulate hasNewImage.
Prefer getLastImageWithFullSizeReceiver, if you are not sure if the image is actually needed, to save resources.
- Returns:
the latest image in full size.
-
getLastImageWithFullSizeReceiver
@Nullable() ImageReceiver getLastImageWithFullSizeReceiver()
Get the a receiver for the latest image in full size. This does not check or manipulate hasNewImage.
The receiver does not copy the image if no getter is called.
- Returns:
a receiver for the latest image in full size.
-
getHighResolutionImage
AnylineImage getHighResolutionImage()
-
takeHighResolutionImage
void takeHighResolutionImage()
Takes a picture from the camera and calls onImageTaken after the image is taken successfully. If no HighResolutionImageListener is set, the method returns. Additionally, a picture is only taken if the safeToTakePicture flag is set to true, which means the camera is open and preview is started.
-
takeHighResolutionImage
void takeHighResolutionImage(int top, int left, int right, int bottom, int scanViewWidth, int scanViewHeight)
-
setFlashOn
void setFlashOn(boolean isOn)
Turn the torch flash on or off.
- Parameters:
isOn- true to turn the flash on false to turn it off
-
setupZoomHandler
void setupZoomHandler(View view)
Set up the zoom for the camera
-
setCustomZoomLevel
void setCustomZoomLevel(int zoomLevel)
-
setMaxZoomRatio
void setMaxZoomRatio(double maxZoomRatio)
Set a maximum zoom ratio
-
setMaxFocalLength
void setMaxFocalLength(double maxFocalLength)
Set a maximum focal length
-
setMinCameraExposure
void setMinCameraExposure()
set the minimum camera exposure
-
setExposureForBlackOnBlack
void setExposureForBlackOnBlack()
-
setDefaultCameraExposure
void setDefaultCameraExposure()
set default camera exposure
-
getMinCameraExposure
int getMinCameraExposure()
- Returns:
minimum camera exposure
-
getMaxCameraExposure
int getMaxCameraExposure()
- Returns:
maximum camera exposure
-
getCurrentFocalLength
double getCurrentFocalLength()
Get the current focal length
-
callAutoFocus
void callAutoFocus()
Call auto focus.
-
openCameraInBackground
void openCameraInBackground()
Open the camera in a background thread, if surface is already created and camera is not opened already. Reports opening or error to the CameraOpenListener set with setCameraOpenListener.
-
openCameraInBackgroundSuccessfully
boolean openCameraInBackgroundSuccessfully()
-
releaseCameraInBackground
void releaseCameraInBackground()
Release the camera in a background thread. Camera releasing may take a bit, so it may interfere with your exit animation. Use this to do it in the background.
ALWAYS call this or releaseCamera in onPause of your activity!!
-
getCameraOrientation
CameraController.CameraOrientation getCameraOrientation()
- Returns:
the camera orientation (only available after the camera is opened)
-
setCameraOrientation
void setCameraOrientation(CameraController.CameraOrientation cameraOrientation)
Allows you to set the camera orientation for the BACK camera.
- Parameters:
cameraOrientation- represents orientation type
-
releaseCamera
void releaseCamera()
Release the camera.
ALWAYS call this or releaseCameraInBackground in onPause of your activity!!
-
resetPreviewCallback
void resetPreviewCallback()
Reset the preview callback. NOTE: This should only be called manually in very special circumstances (e.x.: after the surface is used as a preview for recording a video ).
-
setFocusRegionToCutout
void setFocusRegionToCutout(@NonNull() Context context, @NonNull() RectF cutOutRect, float surfaceWidth, float surfaceHeight)
Updates the focus and metering region to be the same as the given cutout.
- Parameters:
context- the contextcutOutRect- the cutout rect relative to the surfacesurfaceWidth- the width of the surfacesurfaceHeight- the height of the surface
-
setFocalLength
void setFocalLength(double focalLength)
Set a zoom level through focal length
-
-
-
-