Barcode Capture

Defined in namespace Scandit.DataCapture.Barcode.Capture

BarcodeCapture
class BarcodeCapture : IDataCaptureMode

Added in version 6.16.0

Capture mode for single barcode scanning. This capture mode uses the barcode scanning capability.

Learn more on how to use barcode capture in our Get Started guide.

For MatrixScan-based barcode capture, use BarcodeTracking instead.

It cannot be used together with other capture modes that require the same capabilities, e.g. BarcodeTracking.

Create()
static BarcodeCapture Create(DataCaptureContext context, BarcodeCaptureSettings settings)

Added in version 6.16.0

Construct a new barcode capture mode with the provided context and settings. When the context is not null, the capture mode is automatically added to the context.

Create()
static BarcodeCapture Create(BarcodeCaptureSettings settings)

Added in version 6.16.0

Construct a new barcode capture mode with the provided settings. Calling this method is equivalent to calling :meth:ForDataCaptureContext with null as the context argument.

Enabled
bool Enabled { get;set; }

Added in version 6.16.0

Implemented from IDataCaptureMode. See IDataCaptureMode.Enabled.

PointOfInterest
PointWithUnit PointOfInterest { get;set; }

Added in version 6.16.0

The point of interest overwriting the point of interest of the data capture view. By default, this overwriting point of interest is not set and the one from the data capture view is used.

Use PointWithUnit.Zero to unset the point of interest.

The overwriting point of interest is used to control the center of attention for the following subsystems:

  • Location selection. When no location selection is set, the point of interest defines the location at which the recognition optimizes for reading barcodes.

  • Rendered viewfinders.

ApplySettingsAsync()
Task ApplySettingsAsync(BarcodeCaptureSettings settings)

Added in version 6.16.0

Asynchronously applies the new settings to the barcode scanner. If the scanner is currently running, the task will complete when the next frame is processed, and will use the new settings for that frame. If the scanner is currently not running, the task will complete as soon as the settings have been stored and won’t wait until the next frame is going to be processed.

Feedback
BarcodeCaptureFeedback Feedback { get;set; }

Added in version 6.16.0

Instance of BarcodeCaptureFeedback that is used by the barcode scanner to notify users about Success and Failure events.

The default instance of the Feedback will have both sound and vibration enabled. A default beep sound will be used for the sound.

To change the feedback emitted, the BarcodeCaptureFeedback can be modified as shown below, or a new one can be assigned.

BarcodeCapture barcodeCapture  = ...;
barcodeCapture.Feedback.Success = new Feedback(null, Sound.DefaultSound);
AddListener()
void AddListener(IBarcodeCaptureListener listener)

Added in version 6.16.0

Adds the listener to this barcode capture instance.

In case the same listener is already observing this instance, calling this method will not add the listener again.

RemoveListener()
void RemoveListener(IBarcodeCaptureListener listener)

Added in version 6.16.0

Removes a previously added listener from this barcode capture instance.

In case the listener is not currently observing this instance, calling this method has no effect.

RecommendedCameraSettings
static CameraSettings RecommendedCameraSettings { get; }

Added in version 6.16.0

Returns the recommended camera settings for use with barcode capture.

Context
DataCaptureContext Context { get; }

Added in version 6.16.0

Implemented from IDataCaptureMode. See IDataCaptureMode.Context.

BarcodeScanned
event EventHandler<BarcodeCaptureEventArgs> BarcodeScanned

Added in version 6.16.0

Occurs when a code has been scanned. The newly scanned barcode can be retrieved from BarcodeCaptureSession.NewlyRecognizedBarcode.

This method is invoked from a recognition internal thread. To perform UI work, you must dispatch to the main thread first. After receiving this event, you will typically want to start processing the scanned barcodes. Keep in mind however, that any further recognition is blocked until this method completes. Therefore, if you need to perform a time-consuming operation, like querying a database or opening an URL encoded in the barcode data, consider switching to another thread.

Sometimes, after receiving this event, you may want to pause scanning or to stop scanning completely.

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

    barcodeCapture.Enabled = false;
    
  • To stop scanning, you will need to both disable the capture mode and stop the frame source. While it’s possible to only stop the camera and keep the capture mode enabled, this may lead to additional scan 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 BarcodeScanned events will occur after this call
    barcodeCapture.Enabled = false;
    // Asynchronously turn off the camera
    await barcodeCapture.Context?.FrameSource?.SwitchToDesiredStateAsync(FrameSourceState.Off);
    
SessionUpdated
event EventHandler<BarcodeCaptureEventArgs> SessionUpdated

Added in version 6.16.0

Occurs after a frame has been processed by barcode capture and the session has been updated. In contrast to BarcodeScanned, this event occurs regardless whether a code was scanned or not. If codes were recognized in this frame, this event occurs after BarcodeScanned.

This method is invoked from a recognition internal thread. To perform UI work, you must dispatch to the main thread first. Further recognition is blocked until this method completes. It is thus recommended to do as little work as possible in this method.

See the documentation in BarcodeScanned for information on how to properly stop recognition of barcodes.