Class CameraInstance


  • public class CameraInstance
    extends Object
    Manage a camera instance using a background thread. All methods must be called from the main thread.
    • Constructor Detail

      • CameraInstance

        public CameraInstance​(Context context)
        Construct a new CameraInstance. A new CameraManager is created.
        Parameters:
        context - the Android Context
      • CameraInstance

        public CameraInstance​(CameraManager cameraManager)
        Construct a new CameraInstance with a specific CameraManager.
        Parameters:
        cameraManager - the CameraManager to use
    • Method Detail

      • setDisplayConfiguration

        public void setDisplayConfiguration​(DisplayConfiguration configuration)
      • setReadyHandler

        public void setReadyHandler​(Handler readyHandler)
      • setSurfaceHolder

        public void setSurfaceHolder​(SurfaceHolder surfaceHolder)
      • setCameraSettings

        public void setCameraSettings​(CameraSettings cameraSettings)
        This only has an effect if the camera is not opened yet.
        Parameters:
        cameraSettings - the new camera settings
      • getCameraRotation

        public int getCameraRotation()
        Returns:
        the camera rotation relative to display rotation, in degrees. Typically 0 if the display is in landscape orientation.
      • open

        public void open()
      • configureCamera

        public void configureCamera()
      • startPreview

        public void startPreview()
      • setTorch

        public void setTorch​(boolean on)
      • close

        public void close()
      • isOpen

        public boolean isOpen()
      • isCameraClosed

        public boolean isCameraClosed()
      • requestPreview

        public void requestPreview​(PreviewCallback callback)
      • getCameraManager

        protected CameraManager getCameraManager()
        Returns the CameraManager used to control the camera. The CameraManager is not thread-safe, and must only be used from the CameraThread.
        Returns:
        the CameraManager used
      • getCameraThread

        protected com.journeyapps.barcodescanner.camera.CameraThread getCameraThread()
        Returns:
        the CameraThread used to manage the camera
      • getSurface

        protected CameraSurface getSurface()
        Returns:
        the surface om which the preview is displayed