Select Barcode

Questions, comments and suggestions concerning VintaSoft Barcode .NET SDK.

Moderator: Alex

Post Reply
Posts: 5
Joined: Tue Mar 02, 2010 7:30 pm

Select Barcode

Post by igorot » Tue Mar 02, 2010 10:27 pm

I'm trying to use Barcode.NET with the Twain.NET and wondering if it's possible to manually select a barcode image within a page. In instances that there are more than 1 barcode in a page, I'd want a user to be able to pick the barcode to use for indexing. If so, how? Thanks..

Site Admin
Posts: 1443
Joined: Thu Jul 10, 2008 2:21 pm

Re: Select Barcode

Post by Alex » Wed Mar 03, 2010 9:39 am


You can acquire images from scanner using VintaSoftTwain.NET Library and search barcodes in acquired images using VintaSoftBarcode.NET Library.

Here is a snippet of code:

Code: Select all

' Create a BarcodeReader object
Dim barcodeReader As BarcodeReader = New BarcodeReader()

' Extract only Code 128 barcodes
barcodeReader.Settings.ScanBarcodeTypes = BarcodeType.Code128
' Extract onnly horizontal barcodes
barcodeReader.Settings.ScanDirection = ScanDirection.LeftToRight Or ScanDirection.RightToLeft
' Analyze every 5 row and column
barcodeReader.Settings.ScanInterval = 5
' Extract 10 first barcodes
barcodeReader.Settings.MaxBarcodes = 10

' Manual mode of threshold detection
barcodeReader.Settings.ThresholdMode = ThresholdMode.Manual
' Number of steps between minimal and maximal threshold values
barcodeReader.Settings.ThresholdIterations = 15
' Minimal threshold value
barcodeReader.Settings.Threshold1D = 480
' Maximal threshold value
barcodeReader.Settings.Threshold2D = 550

' Acquire images from scanner and search barcodes in acquired images
   ' Open the scanning library

   ' Select a scanner
   ' Disable UI
   VSTwain1.ShowUI = false

   ' Acquire images
   While VSTwain1.AcquireModal()
       ' Extract barcodes
       Dim Infos() As IBarcodeInfo = barcodeReader.ReadBarcodes(VSTwain1.GetCurrentImage())

      ' If barcodes are detected
       Dim resultString As String
       If Infos IsNot Nothing Or Infos.Length > 1 Then
           ' Get information about extracted barcodes
           resultString = "Codes detected" + Infos.Length.ToString() + "]:" + Environment.NewLine
           Dim i As Integer
           For i = 0 To Infos.Length - 1
               resultString += Infos(i).ToString() + Environment.NewLine
           Next i
       End If
   End While

   ' Close the scanning library
   MsgBox "Scan completed."
Catch ex As TwainException
End Try
Best regards, Alexander

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest