Barcode AR Annotation

Defined in package com.scandit.datacapture.barcode.ar.ui

BarcodeArAnnotationTrigger

Added in version 7.1.0

The conditions that trigger an annotation to be displayed.

HIGHLIGHT_TAP

Added in version 7.1.0

The annotation is shown when the user taps on the highlight.

HIGHLIGHT_TAP_AND_BARCODE_SCAN

Added in version 7.1.0

The annotation is shown immediately when the barcode is scanned, and can be hidden and shown again by tapping on the highlight.

BarcodeArAnnotation
interface BarcodeArAnnotation

Added in version 7.1.0

Common interface for Barcode Ar annotations. Annotations are used to display additional information and/or trigger actions. They are displayed outside of the area of a barcode, and attach to the scanned barcode. They are available in different types and have configurable styles. Currently, three types of highlights are supported: BarcodeArInfoAnnotation, BarcodeArPopoverAnnotation and BarcodeArStatusIconAnnotation.

Info annotation Popover annotation Status icon annotation

You can also create your own custom annotation by extending BarcodeArAnnotation. For instance, the following code creates a custom annotation that displays a custom image on top of the barcode:

private class CustomAnnotation(
    val context: Context
) : BarcodeArAnnotation {

    override var annotationTrigger: BarcodeArAnnotationTrigger =
        BarcodeArAnnotationTrigger.HIGHLIGHT_TAP_AND_BARCODE_SCAN

    override fun createView(): View {
        return ImageView(context).apply {
            layoutParams = ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT
            )
            setImageResource(R.drawable.custom_annotation)
            setPadding(10, 10, 10, 10)
        }
    }

    override fun update(
        barcodeLocation: Quadrilateral,
        highlightViewLocation: Quadrilateral?,
        view: View
    ) {
        val location = highlightViewLocation ?: barcodeLocation

        view.x = location.center.x - view.width / 2f
        view.y = location.topCenter.y - view.height
    }
}
update(barcodeLocation, highlightViewLocation, view)
void update(@NonNull Quadrilateral barcodeLocation,
        @NonNull Quadrilateral highlightViewLocation,
        @NonNull View view)

Added in version 7.3.0

Called to update the view with barcode location and highlight location. Called from the main thread. This method should not be called directly, it will be invoked automatically when needed.

createView()
@NonNull View createView()

Added in version 7.3.0

Called once to get the view that will be updated with barcode location in update(). Called from the main thread.

annotationTrigger
BarcodeArAnnotationTrigger getAnnotationTrigger()
void setAnnotationTrigger(BarcodeArAnnotationTrigger value)

Added in version 7.1.0

The trigger that causes the annotation to be presented.