B4J Library [BANano] Dynamsoft Barcode Reader

I've created the B4X version of this Barcode SDK and here is the BANano version.

Dynamsoft Barcode Reader is written in C++. They provide a JavaScript version which uses WebAssembly.

The library can read local images or do a live scan.

Decode an image:

B4X:
Private Sub decodeButton_Click (event As BANanoEvent)
    resultContainer.Element.SetHTML("Decoding...")
    Dim results As List=BANano.Await(reader.decode(codeImage.Src))
    Dim sb As StringBuilder
    sb.Initialize    
    Dim index As Int
    For Each tr As TextResult In results        
        index=index+1
        sb.Append(index).Append(". ")        
        sb.Append(tr.Text)
        sb.Append("<br/>")        
    Next
    resultContainer.Element.SetHTML(sb.ToString)
End Sub

Screenshot_2021-05-18-15-34-58.png


Start live scan and get the result in callback:

B4X:
Private Sub scanButton_Click (event As BANanoEvent)
    scanner.show
End Sub

private Sub scanner_onUnduplicatedRead(txt As String,result As TextResult)
    resultLabel.Text=result.Text
    SKModal1.Open    
End Sub

private Sub scanner_onFrameRead(results() As TextResult)

End Sub
Screenshot_2021-05-18-16-05-01-1.png


A live demo: https://pwa.xulihang.me/barcodereader/

The whole project is uploaded.
 

Attachments

  • BarcodeReader_Banano.zip
    10.9 KB · Views: 190

xulihang

Active Member
Licensed User
Longtime User
Hi @alwaysbusy,

In the TextResult.bas, I tried to return an array of a custom class. But I ran into an Uncaught SyntaxError: Unexpected identifier error.

B4X:
'bug of BANano, unable to return Point2D()
Public Sub getResultPoints As Object
    Return mResultPoints
End Sub
 

alwaysbusy

Expert
Licensed User
Longtime User
Yes, I see that too. Somehow the transpiler does not see the result as an array. I will look into that.

For the moment, probably the easiest what you could do is returning a List, and then you can use:
B4X:
        Dim points As List = tr.ResultPoints
        For k = 0 To points.size - 1
            Dim p As Point2D = points.get(k)
            Log(p.x)
            Log(p.y)
        Next

Thanks for reporting this!

Alwaysbusy
 
Top