Recognize a Barcode
Once your image has been acquired and pre-image processing has been performed to recognize the barcode on the image, the following properties must first be set:
Checks Before Barcode Recognition
If possible, the following properties should be set before the detection process is started:
| Property | Description | ||
| InkColor | The default barcode color is black. | ||
| Orientation | The default barcode orientation is horizontal/vertical orientations. | ||
| BarcodeTypes |
The type of barcodes you want to detect. The default is all 1D barcodes. See the BarcodeTypes property for specific identification of barcode types that must be explicitly set to be recognized, and how to speed up barcode detection for known barcode types.
| ||
| MaximumBarcodes | Sets the maximum number of barcodes that will be detected. The default is 100. If you know how many barcodes you expect to find, set the MaximumBarcodes to that value, and Barcode Xpress v7 will stop looking once that number is found. |
Once these properties are set you are ready to recognize the barcode on the image.
Barcode Xpress detects all barcodes in an image and gives you complete details about them.
If you know where on the image the barcodes reside, setting the Area values to define a smaller rectangular area on your image will speed up processing. By default these values are set to 0 which tells Barcode Xpress to search the entire image automatically.
Supported Barcodes for Recognition
Barcodes supported for recognition are listed in the Overview of Barcode Xpress. The edition you have enabled will determine exact barcodes. To modify editions, see the Trial Mode | Changing BarcodeXpress Edition topic for more information.
Once the BarcodeTypes property has been determined as stated in the Acquire Image topic, use the following methods and properties to recognize the barcode.
Methods
| Method | Description |
| Analyze(Bitmap) | This method detects barcodes within the given bitmap image. |
| Analyze(IntPtr) | This method detects barcodes within the given handle to a DIB (Device Independent Bitmap). |
Properties
| Property | Description |
| AppendCheckSum | This property gets and sets a value which determines if a checksum value is appended to the barcode during recognition. |
| Area | This property gets and sets the area of the image, in pixels, to analyze for barcode recognition. |
| AustralianPostCustomDecodeMode | This property gets and sets the AustrailianPostCustomDecodeType. |
| BarcodeTypes | This property gets and sets the type of barcodes to analyze during recognition processing. |
| IncludeControlCharacters | This property gets and sets the control characters in the barcode value during recognition processing. |
| InkColor | This property gets and sets the ink color of barcodes to search for during recognition processing. |
| MaximumBarcodes | This property gets and sets the maximum number of barcodes to recognize. |
| Orientation | This property gets and sets the orientation of the barcodes to analyze during recognition. |
| ReturnPossibleBarcodes | This property gets and sets a value to determine if possible barcodes are returned in the result list. |
| C# - Minimum C# code to recognize barcodes in an image using Accusoft.BarcodeXpress.Net | Copy Code |
|---|---|
//create and unlock the BarcodeXpress component BarcodeXpress bcx = new BarcodeXpress(); bcx.Licensing.UnlockRuntime(12345, 12345, 12345, 12345); //load a 1BPP, black and white image into the ImagXpressT control imageXView1.Image = Accusoft.ImagXpressSdk.ImageX.FromFile(imagXpress1, "C:\\testbarcodeimage.tif"); //set barcode types to search for System.Array currentBarcodeTypes = new BarcodeType[2]; currentBarcodeTypes.SetValue(BarcodeType.Industry2of5Barcode, 0); currentBarcodeTypes.SetValue(BarcodeType.Interleaved2of5Barcode, 1); bcx.reader.BarcodeTypes = currentBarcodeTypes; //call AnalyzeBarcode to detect barcodes in image //all detected barcodes result, will be returned to the Result object array. Result[] results = bcx.reader.Analyze(imageXView1.Image.ToHdib(false)); //get some results info, if any for (short i = 0; i < results.Length; i++) { //get result for current barcode Result curResult = (Result)results.GetValue(i); ; //do something with results MessageBox.Show(curResult.BarcodeName); MessageBox.Show(curResult.BarcodeValue); } // dispose of the barcode component bcx.Dispose(); | |
See the Overview of Barcode Xpress topic for code examples on recognizing barcodes.
See the Acquire an Image for Barcode Recognition for more code examples.
To obtain the results after analyzing the barcode on an image, see the Access Results topic.

