The idea behind the following algorithm is to rotate the image in steps of 10 degrees. This works, because to detect a barcode only one scan line must be in the interior of the barcode.
![]() | ![]() |
| This barcode is detected. | This barcode is not detected. |
To save some time, the rotation is only done from 0 to 90 degrees. The angles between 90 and 360 can be calculated by applying additional 90 degree rotates.
The algorithm
Public Function ReadBarcodes(ByVal img As gmseBitmap) As gmseBarcodeInfo() Dim alpha As Double Dim delta As Double = 10 Dim bcs As gmseBarcodeInfoCollection Dim bc As gmseBarcodeInfo Dim hash As New Hashtable Dim i As Integer Dim rotimg As gmseBitmap Dim arrbc() As gmseBarcodeInfo While alpha < 90 If alpha = 0 Then rotimg = img Else rotimg = img.Rotate(alpha) End If For i = 0 To 3 bcs = rotimg.ReadBarcodes AddBarcodesToHash(hash, bcs) rotimg.RotateFlip(RotateFlipType.Rotate90FlipNone) Next alpha += delta End While ReDim arrbc(hash.Count - 1) i = 0 For Each bc In hash.Values arrbc(i) = bc i += 1 Next Return arrbc End Function

