Date: 02-16-2022
Return to Index
created by gbSnippets
Sub ExtractTextFromImage
If IsFalse IsFile("c:\program files (x86)\tesseract-ocr\tesseract") Then ? "OCR Engine Missing!" : Exit Sub
Local temp$
Graphic Clear : Graphic Set Pos(300,350) : Graphic Print Webster("... getting text ...") : Graphic ReDraw
Sleep 1000
Shell( "c:\program files (x86)\tesseract-ocr\tesseract " + Exe.Path$ + "files\image.tif " + Exe.Path$ + "files\ocr.txt", 0)
Open Exe.Path$ + "files\ocr.txt" For Binary As #1 : Get$ #1, Lof(1), temp$ : Close #1
Open Exe.Path$ + "files\ocr.txt" For Output As #1 : Print #1, "*** OCR Text ***" + $CrLf + $CrLf + Trim$(temp$) : Close #1
End Sub
http://www.garybeene.com/sw/gbsnippets.htm