The CameraEnhancer class is the primary class of Dynamsoft Camera Enhancer that defines the camera controlling APIs. It is a subclass of ImageSourceAdapter.

In js end of react-native, CameraEnhancer uses singleton mode. You can only get CaptureVisionRouter instance by CameraEnhancer.getInstance.

Hierarchy (View Summary)

Properties

isaId: string = ""

Methods

  • Closes the currently active camera and stops the video stream.

    Returns void

  • Destroy native instance. This object is no longer available after destroy().

    Returns void

  • Disables one or more previously enabled enhanced features.

    Code Snippet:

    cameraEnhancer.disableEnhancedFeatures(EnumEnhancedFeatures.EF_AUTO_ZOOM | EnumEnhancedFeatures.EF_FRAME_FILTER)
    

    Parameters

    • features: number

      An enum value or a bitwise combination of EnumEnhancedFeatures indicating the features to be disabled.

    Returns void

  • Enable the specified enhanced features. View EnumEnhancedFeatures to learn about these enhanced features. By default, these enhanced features are all disabled.

    Code Snippet:

    cameraEnhancer.enableEnhancedFeatures(EnumEnhancedFeatures.EF_AUTO_ZOOM | EnumEnhancedFeatures.EF_FRAME_FILTER)
    

    Parameters

    • features: number

      An enum value or a bitwise combination of EnumEnhancedFeatures which indicates a series of enhanced features.

    Returns void

  • Get the currently actived focus mode.

    Returns Promise<number>

  • Get the current number of images in the buffer.

    Returns Promise<number>

    • A promise that resolves to the number of images in the buffer.
  • Get the maximum number of images that can be buffered.

    Returns Promise<number>

    • A promise that resolves to the maximum capability of the Buffer.
  • Retrieves the current scan region.

    Returns Promise<undefined | null | DSRect>

    • A promise that resolves current scan region.

    DSRect

  • Get the zoom factor of the camera.

    Returns Promise<number>

    • A promise that resolves current zoom factor.
  • Opens the currently selected camera and starts the video stream.

    Returns void

  • Select a camera with a camera position.

    Parameters

    Returns void

  • Bind a CameraView instance with this CameraEnhancer instance.

    Code Snippet:

    function App(): React.JSX.Element {
    const cameraView = useRef<CameraView>(null);
    const camera = CameraEnhancer.getInstance();
    useEffect(() => {
    camera.setCameraView(cameraView.current!!);
    camera.open();
    }, [camera, cameraView])
    return (<CameraView style={{flex:1}} ref={cameraView}/>);
    }

    Parameters

    Returns void

  • Set the focus point of interest and trigger an one-off auto-focus. After the focus, you can either lock the focalngth or keep the continuous auto focus enabled by configuring the subsequent focus mode.

    Parameters

    • floatX: number

      The x of focus point of interest. The coordinate base of the point is "image".

    • floatY: number

      The y of focus point of interest. The coordinate base of the point is "image".

    • focusMode: number

      The subsequent focus mode.

    Returns void

    EnumFocusMode

  • Set the maximum number of images that can be buffered at any time.

    Parameters

    • count: number

      The maximum capability of the Buffer.

    Returns Promise<void>

  • Sets the scan region within the camera's view which limits the frame acquisition to a specific area of the video feed.

    Code Snippet:

    let scanRegion = {
    top: 25,
    bottom: 75,
    left: 25,
    right: 75,
    measuredInPercentage: true,
    }
    cameraEnhancer.setScanRegion(scanRegion);
    //...
    cameraEnhancer.setScanRegion(null); //Cancel the scan region

    Parameters

    • region: undefined | null | DSRect

      specifies the scan region. If null or undefined, cancel the scan region.

    Returns void

    The region is always specified relative to the original video size, regardless of any transformations or zoom applied to the video display.

    DSRect

  • Set the zoom factor of the camera.

    Parameters

    • factor: number

      The zoom factor.

    Returns void

  • Start fetching images from the source to the Buffer of ImageSourceAdapter.

    Returns void

  • Stop fetching images from the source to the Buffer of ImageSourceAdapter.

    Returns void

  • Turn off the torch.

    Returns void

  • Turn on the torch.

    Returns void

  • Get the singleton instance of CameraEnhancer.

    This method ensures that only one instance of CameraEnhancer is created and reused throughout the application. If an instance already exists, it will return the existing one. Otherwise, it will create a new instance and return it.

    Returns CameraEnhancer

    The singleton instance of CameraEnhancer.

  • Trigger to request the camera permission.

    Returns Promise<void>