Text Capture Listener

Defined in package com.scandit.datacapture.text.capture

TextCaptureListener
interface TextCaptureListener

Added in version 6.1.0

Deprecated since version 6.26.0.

Listener interface for traditional text capture.

onObservationStarted(mode)
void onObservationStarted(@NonNull TextCapture mode)

Added in version 6.1.0

Called when the listener starts observing the text capture instance.

onObservationStopped(mode)
void onObservationStopped(@NonNull TextCapture mode)

Added in version 6.1.0

Called when the listener stops observing the text capture instance.

onTextCaptured(mode, session, data)
void onTextCaptured(@NonNull TextCapture mode,
        @NonNull TextCaptureSession session,
        @NonNull FrameData data)

Added in version 6.1.0

Invoked whenever at least one text has been captured. The newly captured texts can be retrieved from TextCaptureSession.newlyCapturedTexts.

This method is invoked from a recognition internal thread. To perform UI work, you must dispatch to the main thread first.

Inside this method, you will typically want to start processing the captured texts somehow, e.g. by validating the text captured. Depending on the application, you will want to pause, or stop recognition, or continue reading texts:

  • To pause the capture session, but keep the camera (frame source) running, just set the text capture’s enabled property to false.

    captureMode.setEnabled(false);
    
  • To stop the capture session, you will need to both disable the capture mode and stop the frame source. While it is possible to only stop the camera and keep the capture mode enabled, this may lead to additional capture events being delivered, which is typically not desired. The following lines of code show how to disable the capture mode and stop the frame source as well:

    // no more onTextCaptured callbacks will be invoked after this call.
    captureMode.setEnabled(false);
    // asynchronously turn off the camera
    captureMode.getContext().getFrameSource().switchToDesiredState(FrameSourceState.OFF, null);
    

Text Capture Advanced Listener

Defined in package com.scandit.datacapture.text