Python pytesseract nefunguje

Pavel Hudeček edizon na seznam.cz
Pátek Říjen 13 10:53:14 CEST 2023


Díky, pomohlo.

Ale stejně to nevedlo k řešení původníjo problému:
Screenshot waferprobingu, kde je na kulaté šedé ploše 105 barevných 
kostiček a v každé jedno velké písmeno z ABCDEKRVZ (stačilo by rozlišit 
A-E a pak všechny jiné =F) a pod ním menší písmeno a číslo (C4, J10, ..) 
to jsou pozice čipů, ty číst nepotřebuju, pokud jsem si jist s tím že 
jsem zaregistroval všechny valký písmena. Pak je ještě vlevo nahoře 
dvouřádkový text, cca po 10 "náhodných" znacích a vpravo nahoře 
CATEGORY. Nic z toho taky nepotřebuju

Nejlíp dopadl první pokus, easyocr:
vylezlo něco přes 10 řádků, které obsahovaly texty blízké těm nahoře, 
část velkých písmen a část chipID, často ale zmršených, třeba |7 místo J7.
To je nepoužitelné, ale myslel jsem si, že nějaký další dopadne líp...
Bohužel to byl s velkým předstihem nejlepší výsledek...
Nejhůř dopad openCV používající tesreact, z toho vylezlo jen CATEGORY

Asi udělám program, který najde políčka (to je snadné, vnitřky barevné 
okolí a hranice šedé) a pak v nich rozliší ty konkrétní písmena podle 
triviálních znaků jako kde se dotýkají opsaného obdélníku a kde kříží 
vertikální osu.

PH

Dne 12.10.2023 v 19:31 Milan Horák napsal(a):
> Zdravím,
>
> není to náhodou tohle:
>
> ---
> The problem was in my lack of understanding of the module. pytesseract 
> is not an OCR, it is simply a translator that allows users to use 
> googles OCR. This means, in order to use this package, a user must 
> have google's OCR installed ( I downloaded mine from here 
> https://sourceforge.net/projects/tesseract-ocr-alt/files/).
>
> This does NOT; however, solve the full problem. The pytesseract 
> package needs to know where the actual OCR program is located. On line 
> 35 of the pytesseract.py script there is a line that tells pytesseract 
> where to find the actual google OCR tesseract program
>
> tesseract_cmd = 'tesseract'
>
> If you are on windows and you haven't manually added tesseract to your 
> path (if you don't know what that means just follow the next steps) 
> then you need to replace that line with the actual location of the 
> google OCR on your computer. Replacing that line with
>
> tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract'
>
> should allow you to run pytesseract assuming you have correctly 
> installed everything. Took me quite a bit longer than i would care to 
> admit to find the blatantly obvious solution to this issue, but 
> hopefully people with this problem in the future resolve it faster 
> than I did! Thanks and have a good day.
> ---
>
> https://stackoverflow.com/questions/55582511/receiving-pytesseract-not-in-your-path-error-on-the-exact-same-code-that-used 
>
>
> Milan
>
> Dne 12. 10. 23 v 18:20 Pavel Hudeček napsal(a):
>> Dobrý den všem,
>>
>> udělal jsem
>> *pip install pytesseract*
>> Skončilo to
>> /Successfully installed pytesseract-0.3.10/
>>
>> Spustil jsem program:
>> fromPIL importImage importpytesseract img = 
>> Image.open('W130_Final.PNG') text = pytesseract.image_to_string(img) 
>> print(text)
>> A výsledek je:
>> /Traceback (most recent call last)://
>> //  File 
>> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py", 
>> line 255, in run_tesseract//
>> //    proc = subprocess.Popen(cmd_args, **subprocess_args())//
>> //  File 
>> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\subprocess.py", 
>> line 800, in __init__//
>> //    restore_signals, start_new_session)//
>> //  File 
>> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\subprocess.py", 
>> line 1207, in _execute_child//
>> //    startupinfo)//
>> //FileNotFoundError: [WinError 2] Systém nemůže nalézt uvedený soubor//
>> //
>> //During handling of the above exception, another exception occurred://
>> //
>> //Traceback (most recent call last)://
>> //  File "exp-xls.py", line 4, in <module>//
>> //    text = pytesseract.image_to_string(img)//
>> //  File 
>> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py", 
>> line 427, in image_to_string//
>> //    }[output_type]()//
>> //  File 
>> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py", 
>> line 426, in <lambda>//
>> //    Output.STRING: lambda: run_and_get_output(*args),//
>> //  File 
>> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py", 
>> line 288, in run_and_get_output//
>> //    run_tesseract(**kwargs)//
>> //  File 
>> "C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\pytesseract.py", 
>> line 260, in run_tesseract//
>> //    raise TesseractNotFoundError()//
>> //pytesseract.pytesseract.TesseractNotFoundError: tesseract is not 
>> installed or it's not in your PATH. See README file for more 
>> information./
>>
>> Příčemž v path je mimo jiné
>> C:\Users\hudecekp\AppData\Local\Programs\Python\Python37\lib\site-packages\pytesseract\ 
>>
>> kde se nachází i soubor pytesseract.py
>> A readme jsem nenašel.
>>
>> Zkoušel jsem restartovat počítač a taky nepomohlo. Ostatní asi 4 věci 
>> co jsem dnes instaloval přes pip normálně fungují
>>
>> Nějaké nápady?
>>
>> Díky,
>> PH
>>
>>
>> _______________________________________________
>> HW-list mailing list  -  sponsored by www.HW.cz
>> Hw-list na list.hw.cz
>> http://list.hw.cz/mailman/listinfo/hw-list
> _______________________________________________
> HW-list mailing list  -  sponsored by www.HW.cz
> Hw-list na list.hw.cz
> http://list.hw.cz/mailman/listinfo/hw-list



Další informace o konferenci Hw-list