Posts: 54
Threads: 21
Joined: Jul 2019
I want to convert this scanned image into a text file but I have no Idea
Posts: 2,126
Threads: 11
Joined: May 2017
Jul-24-2019, 10:32 AM
(This post was last modified: Jul-24-2019, 10:32 AM by DeaD_EyE.)
You can do this with Pytesseract.
First you need to install Tesseract from google.
Then you install the wrapper with pip:
pip install pytesseract Pillow requests After this it should be ready for use:
import io
import requests
import pytesseract
from PIL import Image
URL = 'https://i.imgur.com/gcq2673.jpg'
raw_data = io.BytesIO(requests.get(URL).content)
img = Image.open(raw_data)
text = pytesseract.image_to_string(img)
print(text) Result:
Output: information and asked another question. “From being kidnapped, how long did it take to get here?” “About thirty
five mimutes,” Lavender said with some certainty. “Are you wwe?” “Yes. They didn’t take my watch. I way taken just
after half past sever, and I way i thiy room being chaimed up at ter past eight.” Dee smiled back at her
encouragingly. “Excellent. Now, concentrate. Way the cor moving quickly most of the time, or did it stop and stort
iv traffic?” “I guesy we spent about five mimutey at traffic lighty and such, but most of the time the car way iv
fourth gear. It'y amazing what you hear wher your eyes are covered up and all you have is your ears.” “Tt
certainly ix,” Dee agreed, “Lavender, I suspect that if we were iv West Lowdow they would have grabbed you closer
to-home. So, assuming we are North, South or East of London, thirty minutey at a average speed of about thirty
nriley av hour meany you could hove travelled around fifteer miley at the most. That would put uy inv Croydow to
the South, Blackheath iw the East or iv Nortiv Londow or Even. Did you crosy w bridge?” Lavender concentrated. “T
dow't know. I couldw't see.” “Think back. If you croysed the Thamey from Lambeth Road yow would howe crossed
Blackfriars Bridge. Most of the bridgey across the Thames hawe expansion jointy. They allow the bridge structure to-
move afew millimetres without cracking the road surface. When cory cross these joints, there’yabvayy av small
shudder and w sound like this.” Dee banged her fisty ow the table a fractiow of w second apart. “There would
probably be four or more of these acrow the bridge. Do yow remember anything like that?” Lavender thought hard,
“Maybe. I think I caw remember that, but I dow’t know whether I'm making myself believe it because you just told
me about it.” “That’y all right. Dow't worry. You're doing very well,” Dee smiled: “Your dad will be proud of you:
Take your time and try to remember. At the moment we can’t rule out any options. Did they say anything during
the journey? Anything at all?” Lavender’ brow creased in concentration. “Yes, they did, they were talking to each
other, but nothing that’y any use, really. It way just wfew minutey before we arrived.” “Lavender, try to- remember
exactly what they said: It might be vital.” “I think they sid something about it being odd for the floodlighty to be
owwhew they weren't everv at home today. They also said Harry wouldt be pleased with the draw today and they
would have to-do better ow Wednesday night. Doey that every make sense to- you?” Dee took w deep breativ. “Yes,
Lavender, it doey. You've done very well to remember all of that. I think I do know where we are, more or lesy. But
we musinit let anyone know about thiy conversation, OK?” Lavender nodded, smiling properly for the first tume. ***
Floodlighty suggested a sporty ground, presumably wlarge one. Not being at home today suggested football or
rugby. A drow suggested football or cricket, but only football would be played again ow Wednesday night. OF
course, Dee realised, it wayprobably Championy League. She remembered Josh talking about it to one of hiv friendy
at the match this afternoow. If only she could remember which team had drow today and way also playing,
again ow Wednesday. Dee quite liked football, but didwt know w great deal about it. She would certainly not have:
considered herself a fam, but some football news way hard to misy. She kyveaw that Arsenal, Spury and Chelseer were-
the Londow teamy in the Championy League, so it had to-be one of those three. She had yeew Chelsecv beat West Hanv
today, and Chelseer had been away, not at home, so it couldwt be thenr. The ground Lavender had passed way not
Chelsen’y. So-that left the two North Londow clubs, Arsenal and Tottenham. She couldn't recall what their scorey
had been today, or whether either one had been at home, but she did know that Spury next home match way
against West Ham. Tickety had been advertised for sale ov the hoardings dozens of times during the match, She,
had narrowed their position doww to North London, which way something. The trouble way that the Emiratey
Stadium, the home of Arsenal, way close to the Al, and White Hart Lane, where Spury played, way close to-the ALO,
both quite fast roady and both easily accessible from the river. Something else popped into- her minds She looked at
her new friend. “Lavender, did yow mentiow someone called Harry?” Lavender nodded. “Ves, they said Harry
would have their guty for gartery if they didw't play better.” “Harry could be their manager. I think Arsene Venger
ithe manager at Arsenal, but I dow't know if Tottenham’y manager iv called Harry,” Dee musecdout loud. “OF
course he im” Lavender almost shouted: “Harry Redknapp. He’y Louise Redknapp’y father iv low. I’ve done
modelling with Louise a few timey. She’y married to Jamie Redknapp. He’y really quite nice.” “Lavender, I could
kisy your” Dee said ay she realised that they were within w few hundred yardy of White Hart Lane, iv Tottenham,
North Londow. She knew approximately where they were, and what kind of building they were iw. Now all she had
to do way work out how they were going to get out of there. Commercial Road, Tottenham, North Londen.
Saturday, lopm. Lavender had been talking for w while and Dee had explained why she was dressed iw ov jumpsuit.
lavender didn’t need to explain why she way dresed the way she way. The last hour had beer something of ov
confessional, where Dee had listened to w little girl lost who- thought she way aw adult and so- behaved like one.
Whew Lavender listened to Dee and heard about her experiences, she suddenly realised that here way a sibstantive:
women who was beautiful and tough and who felt no desire for celebrity. Wax her shrink right, she wondered for
the first tome? Way Lavender Fisher w lost soul seeking fame through notoriety, just avher mother and father had
done? They had settled doww eventually, and no doubt Lavender would, too, one day, but they had both enjoyed:
successful coveery iv the full glare of celebrity. Lavender had hosted w few TV showy because she way Dow Fisher’y
daughter, but she hadw't actually achieved anything iw her oww right. Lavender confiled iw Dee that when they
eventually got out of this mess, she would go into rehalr and come off alcohol and drugs. Dee spoke to- her like av
kindly older sister. “Lavender, that’s the wrong move. All yow would be doing iv making someone else responsible
for getting yow sober and cleaw. Even if it works, because you didn't do-it yourself; you'll slip back. Yow need to-do
something constructive, something to give your life direction. Why don't you come and work with me for two-
monthy ay ow intern? Lwe at home. Get yourself sorted out and IW show you what w real job looky like.” “Yow would
do that for me?” Lavender asked, surprised, “Yes, I would. Believe me whew sy that I’ve helped girly wv a much
worse state then you. Girly who have beew trafficked for sex and exploited by evil people iwthe name of profit or
cult religion. It worked for them, and it caw work for you, too, if you really want it to. Now, remember the plan. We
have to stick with it, OK?” © From the first minute she had been taken, Dee had expected that thiy moment would
come, and yo she had prepared herself and couched Lavender. Two of the masked mew stood at the end of the table.
with w video camera: They were the two whow Dee had ujured. They were clearly still suffering, judging by their
fidgeting and complaiming. Piet gave the girls their orders. “Thiy video wil last a minute and not w second
The benefit is, that this library works offline. No connection to the internet is needed to convert local images into text.
Tesseract is still developed by google.
Posts: 54
Threads: 21
Joined: Jul 2019
Jul-24-2019, 10:55 AM
(This post was last modified: Jul-25-2019, 12:02 AM by scidam.)
(Jul-24-2019, 10:32 AM)DeaD_EyE Wrote: You can do this with Pytesseract.
First you need to install Tesseract from google.
Then you install the wrapper with pip:
pip install pytesseract Pillow requests After this it should be ready for use:
import io
import requests
import pytesseract
from PIL import Image
URL = 'https://i.imgur.com/gcq2673.jpg'
raw_data = io.BytesIO(requests.get(URL).content)
img = Image.open(raw_data)
text = pytesseract.image_to_string(img)
print(text) Result:
Output: information and asked another question. “From being kidnapped, how long did it take to get here?” “About thirty
five mimutes,” Lavender said with some certainty. “Are you wwe?” “Yes. They didn’t take my watch. I way taken just
after half past sever, and I way i thiy room being chaimed up at ter past eight.” Dee smiled back at her
encouragingly. “Excellent. Now, concentrate. Way the cor moving quickly most of the time, or did it stop and stort
iv traffic?” “I guesy we spent about five mimutey at traffic lighty and such, but most of the time the car way iv
fourth gear. It'y amazing what you hear wher your eyes are covered up and all you have is your ears.” “Tt
certainly ix,” Dee agreed, “Lavender, I suspect that if we were iv West Lowdow they would have grabbed you closer
to-home. So, assuming we are North, South or East of London, thirty minutey at a average speed of about thirty
nriley av hour meany you could hove travelled around fifteer miley at the most. That would put uy inv Croydow to
the South, Blackheath iw the East or iv Nortiv Londow or Even. Did you crosy w bridge?” Lavender concentrated. “T
dow't know. I couldw't see.” “Think back. If you croysed the Thamey from Lambeth Road yow would howe crossed
Blackfriars Bridge. Most of the bridgey across the Thames hawe expansion jointy. They allow the bridge structure to-
move afew millimetres without cracking the road surface. When cory cross these joints, there’yabvayy av small
shudder and w sound like this.” Dee banged her fisty ow the table a fractiow of w second apart. “There would
probably be four or more of these acrow the bridge. Do yow remember anything like that?” Lavender thought hard,
“Maybe. I think I caw remember that, but I dow’t know whether I'm making myself believe it because you just told
me about it.” “That’y all right. Dow't worry. You're doing very well,” Dee smiled: “Your dad will be proud of you:
Take your time and try to remember. At the moment we can’t rule out any options. Did they say anything during
the journey? Anything at all?” Lavender’ brow creased in concentration. “Yes, they did, they were talking to each
other, but nothing that’y any use, really. It way just wfew minutey before we arrived.” “Lavender, try to- remember
exactly what they said: It might be vital.” “I think they sid something about it being odd for the floodlighty to be
owwhew they weren't everv at home today. They also said Harry wouldt be pleased with the draw today and they
would have to-do better ow Wednesday night. Doey that every make sense to- you?” Dee took w deep breativ. “Yes,
Lavender, it doey. You've done very well to remember all of that. I think I do know where we are, more or lesy. But
we musinit let anyone know about thiy conversation, OK?” Lavender nodded, smiling properly for the first tume. ***
Floodlighty suggested a sporty ground, presumably wlarge one. Not being at home today suggested football or
rugby. A drow suggested football or cricket, but only football would be played again ow Wednesday night. OF
course, Dee realised, it wayprobably Championy League. She remembered Josh talking about it to one of hiv friendy
at the match this afternoow. If only she could remember which team had drow today and way also playing,
again ow Wednesday. Dee quite liked football, but didwt know w great deal about it. She would certainly not have:
considered herself a fam, but some football news way hard to misy. She kyveaw that Arsenal, Spury and Chelseer were-
the Londow teamy in the Championy League, so it had to-be one of those three. She had yeew Chelsecv beat West Hanv
today, and Chelseer had been away, not at home, so it couldwt be thenr. The ground Lavender had passed way not
Chelsen’y. So-that left the two North Londow clubs, Arsenal and Tottenham. She couldn't recall what their scorey
had been today, or whether either one had been at home, but she did know that Spury next home match way
against West Ham. Tickety had been advertised for sale ov the hoardings dozens of times during the match, She,
had narrowed their position doww to North London, which way something. The trouble way that the Emiratey
Stadium, the home of Arsenal, way close to the Al, and White Hart Lane, where Spury played, way close to-the ALO,
both quite fast roady and both easily accessible from the river. Something else popped into- her minds She looked at
her new friend. “Lavender, did yow mentiow someone called Harry?” Lavender nodded. “Ves, they said Harry
would have their guty for gartery if they didw't play better.” “Harry could be their manager. I think Arsene Venger
ithe manager at Arsenal, but I dow't know if Tottenham’y manager iv called Harry,” Dee musecdout loud. “OF
course he im” Lavender almost shouted: “Harry Redknapp. He’y Louise Redknapp’y father iv low. I’ve done
modelling with Louise a few timey. She’y married to Jamie Redknapp. He’y really quite nice.” “Lavender, I could
kisy your” Dee said ay she realised that they were within w few hundred yardy of White Hart Lane, iv Tottenham,
North Londow. She knew approximately where they were, and what kind of building they were iw. Now all she had
to do way work out how they were going to get out of there. Commercial Road, Tottenham, North Londen.
Saturday, lopm. Lavender had been talking for w while and Dee had explained why she was dressed iw ov jumpsuit.
lavender didn’t need to explain why she way dresed the way she way. The last hour had beer something of ov
confessional, where Dee had listened to w little girl lost who- thought she way aw adult and so- behaved like one.
Whew Lavender listened to Dee and heard about her experiences, she suddenly realised that here way a sibstantive:
women who was beautiful and tough and who felt no desire for celebrity. Wax her shrink right, she wondered for
the first tome? Way Lavender Fisher w lost soul seeking fame through notoriety, just avher mother and father had
done? They had settled doww eventually, and no doubt Lavender would, too, one day, but they had both enjoyed:
successful coveery iv the full glare of celebrity. Lavender had hosted w few TV showy because she way Dow Fisher’y
daughter, but she hadw't actually achieved anything iw her oww right. Lavender confiled iw Dee that when they
eventually got out of this mess, she would go into rehalr and come off alcohol and drugs. Dee spoke to- her like av
kindly older sister. “Lavender, that’s the wrong move. All yow would be doing iv making someone else responsible
for getting yow sober and cleaw. Even if it works, because you didn't do-it yourself; you'll slip back. Yow need to-do
something constructive, something to give your life direction. Why don't you come and work with me for two-
monthy ay ow intern? Lwe at home. Get yourself sorted out and IW show you what w real job looky like.” “Yow would
do that for me?” Lavender asked, surprised, “Yes, I would. Believe me whew sy that I’ve helped girly wv a much
worse state then you. Girly who have beew trafficked for sex and exploited by evil people iwthe name of profit or
cult religion. It worked for them, and it caw work for you, too, if you really want it to. Now, remember the plan. We
have to stick with it, OK?” © From the first minute she had been taken, Dee had expected that thiy moment would
come, and yo she had prepared herself and couched Lavender. Two of the masked mew stood at the end of the table.
with w video camera: They were the two whow Dee had ujured. They were clearly still suffering, judging by their
fidgeting and complaiming. Piet gave the girls their orders. “Thiy video wil last a minute and not w second
The benefit is, that this library works offline. No connection to the internet is needed to convert local images into text.
Tesseract is still developed by google.
what about the lang isn't it too hard to identify
Error: Traceback (most recent call last):
File "C:\Python 3\lib\site-packages\pytesseract\pytesseract.py", line 184, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "C:\Python 3\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Python 3\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Python.py", line 10, in <module>
text = pytesseract.image_to_string(img)
File "C:\Python 3\lib\site-packages\pytesseract\pytesseract.py", line 309, in image_to_string
}[output_type]()
File "C:\Python 3\lib\site-packages\pytesseract\pytesseract.py", line 308, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Python 3\lib\site-packages\pytesseract\pytesseract.py", line 218, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Python 3\lib\site-packages\pytesseract\pytesseract.py", line 186, in run_tesseract
raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path
Posts: 2,126
Threads: 11
Joined: May 2017
A better error description is not possible.
Error: tesseract is not installed or it's not in your path
The tesseract dependency from google is not in the Path.
Maybe you haven't installed tesseract, just only the wrapper PyTesseract
or there was an error during installation.
Posts: 54
Threads: 21
Joined: Jul 2019
(Jul-24-2019, 01:06 PM)DeaD_EyE Wrote: A better error description is not possible.
Error: tesseract is not installed or it's not in your path
The tesseract dependency from google is not in the Path.
Maybe you haven't installed tesseract, just only the wrapper PyTesseract
or there was an error during installation.
Can we chat in messages about it
Posts: 2,126
Threads: 11
Joined: May 2017
Jul-30-2019, 07:57 PM
(This post was last modified: Jul-30-2019, 07:57 PM by DeaD_EyE.)
On Ubuntu 18.x:
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev On Windows:
This may work: https://github.com/UB-Mannheim/tesseract/wiki
PyTesseract is just a nice Python-Wrapper around Tesseract. Without Tesseract, no PyTesseract.
|