Reading a Barcode#
The Web UI shows the camera image. The decoded text is not shown there. Your application receives the text on the recipe data topic.
What You Need#
- A Basler Vision Connector setup with a visible camera image. See From the Marketplace to the First Image.
- pylon version 26.10 or lower. The Basler Vision Connector doesn't support vTool recipes that you create or edit in a pylon version higher than 26.10.
- A Barcode Reader vTool recipe saved as a .precipe file.
- A pylon vTools license for the Barcode Reader. You need this license in the pylon Viewer to create the recipe.
- A Basler Vision Connector vTools license for the Barcode Reader, to run the recipe in the Basler Vision Connector. See vTools Licenses.
Create the Recipe#
Create the recipe in the Workbench of the pylon Viewer. For the general recipe steps, see Working with Recipes.
- Add a Barcode Reader vTool.
- Add a pin on the input terminal and connect it to the Image input pin of the Barcode Reader. The Basler Vision Connector passes the camera image into the recipe through this input terminal pin.
- Connect the Texts output pin of the Barcode Reader to the output terminal and name that output terminal pin. The recipe payload publishes the decoded string under this pin name. To publish the barcode type as well, connect the Types output pin to the output terminal and name that output terminal pin.
- Name the input terminal pin that receives the camera image
Image0_{UserDefinedPinID}, for exampleImage0_BarcodeCamera. Pin names are case-sensitive. See Naming of Input Pins. - If the recipe contains a Camera vTool or an Image Loading vTool, deactivate that vTool before you upload the recipe. See Restrictions.
- To limit the area in which the Barcode Reader searches, add an ROI Creator vTool and connect it to the Roi input pin of the Barcode Reader.
- Save the recipe in pylon version 26.10 or lower.
Don't add AI vTools to this recipe. The Basler Vision Connector can't run recipes that contain AI vTools.
Use the Recipe in the Web UI#
Follow Using vTools in the Basler Vision Connector Web UI:
- Upload the .precipe file.
- Create a recipe instance.
- Open the camera in the Cameras list.
- Assign the open camera to the image pin of the recipe instance.
- Start image acquisition.
- Check the image in the image display area and the Message Log. The image display area shows the camera image, not the barcode result.
- Copy the recipe data topic shown in the Web UI after the pins are assigned, and subscribe to it from your application. See the Messaging Concept.
Use the Recipe via Messaging#
You can upload and run the same recipe with JSON messages:
- Upload the recipe.
- Create a recipe instance.
- Open the camera connection.
- Assign the camera to the recipe pin.
- Start image streaming.
- Subscribe to the recipe data topic. On ZeroMQ, the topic is
cstm_recipe/{RecipeID}/data. On MQTT, the topic is{mqttRoot}/cstm_recipe/{RecipeID}/data. The payload format is described in Recipe Payload Format.
The full message list is in Recipe Support for vTools.
How You Know It Works#
- The image display area shows a stable camera image.
- The Message Log shows no recipe error.
- Your application receives the decoded string on the recipe data topic, under the name of the output terminal pin connected to the Texts pin of the Barcode Reader.
JSON Test Files#
To try the messaging path in Flow Creator, start with Using the JSON Test Files with Industrial Edge Flow Creator. The test files are:
- MQTT JSON Test File
- MQTT JSON Test File with vTools
- ZeroMQ JSON Test File
- ZeroMQ JSON Test File with Image Viewer
For a recipe, use the MQTT JSON test file with vTools.