BarcodeDetection

class BarcodeDetectionPrediction(box, barcode_type, info)

A single prediction from BarcodeDetection.

Parameters
  • box (ndarray) – The vertices of the detected barcode.

  • barcode_type (str) – The type of barcode. Supported: [‘None’, ‘EAN_8’, ‘EAN_13’, ‘UPC_A’, ‘UPC_E’, ‘UPC_EAN_EXTENSION’]

  • info (str) – The decoded barcode information

property box

The bounding box around the detected barcode.

Return type

ndarray

property barcode_type

The type of detected barcode. Supported - [‘None’, ‘EAN_8’, ‘EAN_13’, ‘UPC_A’, ‘UPC_E’, ‘UPC_EAN_EXTENSION’]

Return type

str

property info

The extracted barcode information

Return type

str

class BarcodeDetectionResults(predictions, image)

All the results of barcode detection from BarcodeDetection.

Parameters
  • predictions (List[BarcodeDetectionPrediction]) – The boxes, type and info for each prediction(detection).

  • image (ndarray) – The image that the detection was performed on.

property predictions

The list of predictions.

Return type

List[BarcodeDetectionPrediction]

property image

The image the results were processed on.

Return type

ndarray

markup_image()

Draw detected barcode boxes on the image.

Return type

ndarray

Returns

The marked-up image

crop_localized()

Crop the detected barcode boxes from the image.

Return type

List[ndarray]

Returns

The list of cropped barcode images

class BarcodeDetection

Locate, detect and decode the barcode(s) within an image.

Typical usage:

barcode_detector = edgeiq.BarcodeDetection()

<get image>
results = barcode_detector.localize_decode(image)
image = results.markup_image()

for prediction in results.predictions:
    text.append("{}: {}".format(
                prediction.barcode_type, prediction.info))
localize_decode(image)

Localizes and decodes barcodes in an image.

Parameters

image (ndarray) – The image to analyze.

Return type

BarcodeDetectionResults

localize(image)

Localize barcode(s) within an image.

Parameters

image (ndarray) – The image to analyze in BGR format.

Return type

ndarray

Returns

The boxes around localized barcodes

decode(image, boxes)

Decodes localized barcode(s).

Parameters
Return type

BarcodeDetectionResults

publish_analytics(results, tag=None, **kwargs)

Publish Barcode Detection results to the alwaysAI Analytics Service

Example usage:

try:
    barcode_detector.publish_analytics(results, tag='custom_tag')
except edgeiq.PublishError as e:
    # Retry publish
except edgeiq.ConnectionError as e:
    # Save state and exit app to reconnect
Parameters
  • results (BarcodeDetectionResults) – The results to publish.

  • tag (Optional[Any]) – Additional information to assist in querying and visualizations.

Raises

ConnectionBlockedError when using connection to the alwaysAI Device Agent and resources are at capacity,

Raises

PacketRateError when publish rate exceeds current limit,

Raises

PacketSizeError when packet size exceeds current limit. Packet publish size and rate limits will be provided in the error message.