Data Capture Mode#
Defined in package com.scandit.datacapture.core.capture
Added in version 6.0.0
DataCaptureMode is the interface implemented by all data capture modes. A data capture mode encapsulates a specific way of capturing data, such as barcode capture, barcode tracking, text capture, or label capture. Each capture mode can be individually enabled and disabled to switch between different ways of capturing data.
Capture modes are restricted to the set of data captures modes provided by the Scandit Data Capture SDK. It is not available for implementing custom data capture modes.
Capture modes need to be associated with a data capture context after they have been created using DataCaptureContext.addMode(). This is done automatically when using any of the factory methods such as BarcodeCapture.forDataCaptureContext(), BarcodeTracking.forDataCaptureContext(), TextCapture.forDataCaptureContext() or LabelCapture.forDataCaptureContext() and specifying a context. If no context is specified for the factory methods, the mode has to be manually added. Modes can be removed again using DataCaptureContext.removeMode().
Multiple data capture modes can be associated with the same context. However, there are restrictions on which data capture modes can be used together. These restrictions are expressed in terms of capabilities that the capture modes require, for example barcode scanning and barcode tracking both require the capability to scan barcodes. No two capture modes that require the same capabilities can be used with the same data capture context. When conflicting requirements are detected, the data capture context will not process any frames and report a context status error with code 1028.
Because the DataCaptureMode cannot be instantiated directly, the example below uses the BarcodeCapture to illustrate a typical usage of capture modes. Other capture modes will work very similarly. The typical steps are:
Configure the capture mode by first creating settings.
Instantiate the capture mode and associate with the context and the settings.
Registering a mode-specific listener (not shown).
Enabling recognition by setting the isEnabled property to true.
DataCaptureContext dataCaptureContext = ...; BarcodeCaptureSettings settings = new BarcodeCaptureSettings(); settings.enableSymbology(Symbology.QR, true); BarcodeCapture barcodeCapture = BarcodeCapture.forDataCaptureContext(dataCaptureContext, settings); // Capture modes are enabled by default. The next line is not strictly necessary and // is only listed to make you aware of the possibility to enable/disable modes. barcodeCapture.setEnabled(true);
If you’re using androidx.fragments dependency and have the situation where a scanning fragment navigates to another scanning fragment with an incompatible mode, make sure you’re using version 1.3.0+ of the dependency. If not, you may run into an incompatible modes error, as the new fragment gets resumed before the previous is paused and for some time incompatible modes may be enabled in the DataCaptureContext at the same time. This results in sessions being empty of any result.
Added in version 6.0.0
True if this data capture mode is enabled, false if not. Only enabled capture modes are processing frames.
Changing this property from false to true causes this data capture mode to start processing frames.
Changing this property from true to false causes this data capture mode to stop processing frames. The effect is immediate: no more frames will be processed after the change. However, if a frame is currently being processed, this frame will be completely processed and deliver any results/callbacks to the registered listeners. When changing this property from one of the listener callbacks that is called as a result of processing the frame, no more frames will be processed after that.
Note that this property only affects the data capture and does not affect the FrameSource’s state.
By default, this property is true.