Reading a Bar Code of Known Location Code Snippet

This code snippet shows how to specify the bar code position and perform the bar code reading.

C++

#include <eVision/EasyBarCode/EasyBarCode1/EBarCode.h>
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// Bar code reader constructor
EBarCode reader;
// String for the decoded bar code
std::string result;
// ...
// Disable automatic bar code detection
reader.SetKnownLocation(true);
// Set the bar code position
reader.SetCenterXY(450.0f, 400.0f);
reader.SetSize(250.0f, 110.0f);
reader.SetReadingSize(1.15f, 0.5f);
// Read the bar code at the specified location
result = reader.Read(&srcImage);

C#

using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// Bar code reader constructor
eVision.EBarCode reader = new eVision.EBarCode();
// String for the decoded bar code
string result;
// ...
// Disable automatic bar code detection
reader.KnownLocation = true;
// Set the bar code position
reader.SetCenterXY(450.0f, 400.0f);
reader.SetSize(250.0f, 110.0f);
reader.SetReadingSize(1.15f, 0.5f);
// Read the bar code at the specified location
result = reader.Read(srcImage);

Python

Warning

This snippet is not available in this language.