# Barcode Reader

This function block reads barcodes and QR codes from image input and returns an annotated image plus decoded information. It works with common barcode types and is designed for quick integration into inspection or logging flows.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Barcode Image` Image that contains a barcode or QR code to be decoded. Can be color or grayscale.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Barcode Image` Annotated image. When a code is detected, the result shows visual markers (boxes/labels) on the image.

`Barcode Type` Detected barcode type (for example QR, CODE128, etc.).

`Barcode Data` Decoded payload contained in the barcode or QR code (text or numeric content).

## 🕹️ Controls <a href="#controls" id="controls"></a>

This function block has no interactive controls. It runs automatically when an image is provided.

## 🎨 Features <a href="#features" id="features"></a>

* Fast barcode and QR decoding on a single image input.
* Visual feedback via annotated image to confirm detection location.
* Returns both the decoded data and the detected code type for downstream processing.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. Provide an image to the `Barcode Image` input from any image-producing block (for example a camera or image loader).
2. Inspect the `Barcode Image` output to verify detection visually.
3. Use the `Barcode Type` and `Barcode Data` outputs to trigger logic, logging, or storage.

## 📊 Evaluation <a href="#evaluation" id="evaluation"></a>

When the block receives an image, it analyzes the frame for barcode patterns. If a code is found, the block outputs an annotated image, the detected code type, and the decoded data. If nothing is found, the annotated image is returned unchanged and the data outputs will indicate no detection.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Combine with `Image ROI Select` to crop the region around a label or package before feeding it to this block. Cropping reduces false detections and speeds up processing.
* If the barcode is small or low-contrast, try `Image Resize` to enlarge the area of interest before decoding.
* Use `Blur` sparingly to reduce noise before decoding when images are grainy; in some cases a mild blur improves detection.
* When barcodes are printed on complex backgrounds, apply `Image Threshold` to increase the contrast between code and background.
* Preview results with `Show Image` to confirm detection and bounding visuals in the UI.
* For automated logging of decoded values, send `Barcode Data` to `CSV Export` or save frames with `Image Logger` for audit trails.
* For batch or file-based workflows, load images with `Load Image From Path` and process them through this block.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* No code detected
  * Ensure the barcode region is clearly visible and not heavily blurred, occluded or too small.
  * Try cropping the area with `Image ROI Select` and increasing the image size with `Image Resize`.
  * Improve contrast using `Image Threshold` or adjust lighting in the capture step.
* Incorrect or garbled data
  * Check image quality and alignment of the code. Rotation or perspective distortion can harm decoding — crop and align the region first.
  * If multiple codes overlap, isolate them using `Image ROI Select` or preprocessing filters.
* Too many false positives
  * Restrict the input area via `Image ROI Select` or add simple filtering (thresholding, color filters) before decoding.

If you need to inspect image frames visually during setup, connect the output to `Show Image` to confirm how the block annotates detected codes.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/detections-shapes/detectors/barcode-reader.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
