can you give me the link " listed in the easyocr tutorial" that i need to copies ?
anyway thank you so much. i will try it again
Here is the Python code you need to save as “EasyOCRimage.py”
Python:
directoryDefault=r'C:\VideoSubFinder5x64\RGBImages'
extensions=[".jpg",".png",".jpeg",".bmp"]
languagesDefault="ch_tra"
import os
import argparse
def main():
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,description=r"easyOcrImage.py -l en,ch_tra -d " + directoryDefault,epilog=codeLanguages)
parser.add_argument('-l','--langs',dest="langs",default=languagesDefault,help="Separated by (,) \"en,ch_tra\" for mix langs english & Traditional Chinese")
parser.add_argument('-d','--directory',dest="directory", default=directoryDefault,help='directory help')
args = parser.parse_args()
if not os.path.isdir(args.directory):
print ("Not exists directory: " + args.directory )
return
parentDirectory = os.path.dirname(args.directory)
directoryTXTResults = os.path.join(parentDirectory, "TXTResults")
if os.path.isdir( directoryTXTResults ):
directoryTxt=directoryTXTResults
else:
directoryTxt=args.directory
os.system("title OCR for " + args.directory + " - " + args.langs)
import easyocr
reader = easyocr.Reader( args.langs.replace(" ","").split(",") )
files = [x for x in os.listdir(args.directory) if os.path.splitext(x)[1] in extensions]
for i,x in enumerate(files):
os.system("title OCR {}/{} Processed".format(i,len(files)) )
fileImage = os.path.join(args.directory,x)
fileTxt = os.path.join(directoryTxt,x)
result = reader.readtext(fileImage,detail=0, paragraph=True)
with open(fileTxt+".txt", "w", encoding="utf-8") as f:
f.write( " ".join(result) )
codeLanguages="""Languages
Code Name
--- ----
abq Abaza
ady Adyghe
af Afrikaans
ang Angika
ar Arabic
as Assamese
ava Avar
az Azerbaijani
be Belarusian
bg Bulgarian
bh Bihari
bho Bhojpuri
bn Bengali
bs Bosnian
ch_sim Simplified Chinese
ch_tra Traditional Chinese
che Chechen
cs Czech
cy Welsh
da Danish
dar Dargwa
de German
en English
es Spanish
et Estonian
fa Persian (Farsi)
fr French
ga Irish
gom Goan Konkani
hi Hindi
hr Croatian
hu Hungarian
id Indonesian
inh Ingush
is Icelandic
it Italian
ja Japanese
kbd Kabardian
kn Kannada
ko Korean
ku Kurdish
la Latin
lbe Lak
lez Lezghian
lt Lithuanian
lv Latvian
mah Magahi
mai Maithili
mi Maori
mn Mongolian
mr Marathi
ms Malay
mt Maltese
ne Nepali
new Newari
nl Dutch
no Norwegian
oc Occitan
pl Polish
pt Portuguese
ro Romanian
ru Russian
rs_cyrillic Serbian (cyrillic)
rs_latin Serbian (latin)
sck Nagpuri
sk Slovak (need revisit)
sl Slovenian
sq Albanian
sv Swedish
sw Swahili
ta Tamil
tab Tabassaran
te Telugu
th Thai
tl Tagalog
tr Turkish
ug Uyghur
uk Ukranian
ur Urdu
uz Uzbek
vi Vietnamese (need revisit)"""
if __name__ == "__main__":
main()