Sub BatchOCR(img As B4XBitmap,boxesList As List) As ResumableSub
Dim names As List
names.Initialize
Dim boxMap As Map
boxMap.Initialize
For Each box As Map In boxesList
Dim cropped As B4XBitmap=croppedAndPreprocessedImage(img,box)
Dim name As String=Utils.saveImgToDiskWithUniqueName(cropped)
names.Add(name)
boxMap.Put(name,box)
OCR.tesseract(name,OcrLang,False)
Next
Dim interval as int=200
Do While names.Size>0
Sleep(interval )
Log(names)
Dim name As String=names.Get(0)
If File.Exists(File.DirApp,name&".txt") Then
Dim box As Map
box=boxMap.Get(name)
box.Put("text",PostProcessedOCRResult(File.ReadString(File.DirApp,name&".txt")))
If OCR.DeleteTesseractTempFiles(name)=True Then
names.RemoveAt(0)
interval =0
Continue
End If
End If
Loop
Return ""
End Sub