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 Camera
camera
public int
maxZoomLevel
public double
zoomRatio
-
Method Summary
Modifier and Type Method Description Camera
getCamera()
int
getMaxZoomLevel()
double
getZoomRatio()
Get the current zoom ratio void
setZoomRatio(double zoomLevelRatio)
Set a zoom level through zoom Ratio void
releaseCameraAndPreview()
Release the camera for the landscape to landscape mode. boolean
hasNewImage()
AnylineYuvImage
getNewImage()
AnylineImage
getLastImageWithFullSize()
Get the latest image in full size. ImageReceiver
getLastImageWithFullSizeReceiver()
Get the a receiver for the latest image in full size. AnylineImage
getHighResolutionImage()
void
takeHighResolutionImage()
Takes a picture from the camera and calls onImageTaken after the image is taken successfully. void
takeHighResolutionImage(int top, int left, int right, int bottom, int scanViewWidth, int scanViewHeight)
void
setFlashOn(boolean isOn)
Turn the torch flash on or off. void
setupZoomHandler(View view)
Set up the zoom for the camera void
setCustomZoomLevel(int zoomLevel)
void
setMaxZoomRatio(double maxZoomRatio)
Set a maximum zoom ratio void
setMaxFocalLength(double maxFocalLength)
Set a maximum focal length void
setMinCameraExposure()
set the minimum camera exposure void
setExposureForBlackOnBlack()
void
setDefaultCameraExposure()
set default camera exposure int
getMinCameraExposure()
int
getMaxCameraExposure()
double
getCurrentFocalLength()
Get the current focal length void
callAutoFocus()
Call auto focus. void
openCameraInBackground()
Open the camera in a background thread, if surface is already created and camera is not opened already. boolean
openCameraInBackgroundSuccessfully()
void
releaseCameraInBackground()
Release the camera in a background thread. CameraController.CameraOrientation
getCameraOrientation()
void
setCameraOrientation(CameraController.CameraOrientation cameraOrientation)
Allows you to set the camera orientation for the BACK camera. void
releaseCamera()
Release the camera. void
resetPreviewCallback()
Reset the preview callback. 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. void
setFocalLength(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, removeAllCameraOpenListeners, removeCameraOpenListener, resetAutoFocusTimer, setCameraControllerListener, setCameraOpenListener, setHighResolutionImageListener, setImageListener, setPreferredCameraConfig, setZoomGestureEnabled
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
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()
-
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
-
-
-
-