Android Question OCR offline - fixed area

LucaMs

Expert
Licensed User
Longtime User
I have seen that there is more than one OCR library for B4A.

Before I start trying them all, I'd like to know if anyone has been able to get the features listed below and then recommend the library to use.

1 - it works offline
2 - the recognition is carried out only in a small rectangle. The ideal would be that only in that rectangle you see what the lens frames, but a rectangle drawn over the full-screen shot would also be fine.


Thank you.
 

ddk1

Member
Licensed User
I use MobileVisionBitmap which seems to work fine. It OCRs a whole bitmap but in theory, you could crop that bitmap before the OCR. Haven't tried it though.
I once tried playing with params TargetWidth & TargetHeight, trying to limit the area read but it didn't seem to work as expected so I don't touch those now.

Example:
Sub Globals
    Private mstrOcrWords As String
End Sub

Sub OcrPic(bmp as BitMap, Left as Int, Top As Int, Width As Int, Height as Int))
    Dim mvbm As MobileVisionBitmap
    mvbm.Initialize("mvbm")
    mvbm.TargetWidth = bmp.Width
    mvbm.TargetHeight = bmp.Height
    mstrOcrWords = ""
    Dim bmp1 As Bitmap = bmp.Crop(Left, Top, Width, Height)
    mvbm.decodeBitmap(bmp1)                'triggers mvbm_blocks_result() & mvbm_words_result()
End Sub           

Sub mvbm_words_result(words As String)
    ' Words are comma delimited
    mstrOcrWords = words
End Sub
 
Upvote 0
Top