New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Latexocr generate completely off result #241
Comments
Can you tell me more about your setup. Do you use a second monitor? Do you have a retina display? I'm still wondering how exactly the screen capture works on macOS. The way you explained the problem, it sounds like the region you select is not actually the region the model gets to see. If you want you can find the https://github.com/lukas-blecher/LaTeX-OCR/blob/main/pix2tex/gui.py#L300 like this: img = ImageGrab.grab(bbox=(x1//factor, y1//factor, x2//factor, y2//factor), all_screens=True)
else:
raise e
+ img.show()
QApplication.processEvents() |
Thank you for the quick response. It's macbook pro 2018 with retina
display. I didn't use a second monitor in the reported case. I
tried adding img.show() as suggested, it turns out the captured image is a
random part of my desktop wallpaper, even if the whole desktop is covered
by some other window. The position of the captured image in the wallpaper
is not related to where I actually capture it.
When I actually use a second monitor, latexocr gives the following error
message
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
gui.py 297 mouseReleaseEvent
img = ImageGrab.grab(bbox=(x1//factor, y1//factor, x2//factor, y2//factor),
all_screens=True)
ImageGrab.py 38 grab
im = Image.open(filepath)
Image.py 3124 open
"cannot identify image file %r" % (filename if filename else fp)
PIL.UnidentifiedImageError:
cannot identify image file
'/var/folders/q7/xqj1xs_13ms9y9327t0t28sc0000gn/T/tmpqnne9nm7.png'
screencapture: -R requires a valid rect (x,y,w,h)
screencapture: -R requires a valid rect (x,y,w,h)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
The file tmpqnne9nm7.png is an empty file. In some cases the file path is
'/tmp/tmpqnne9nm7.png'.
Anyways thank you for the wonderful tool and good luck with your
development!
Best,
H
Lukas Blecher ***@***.***> 于2023年2月17日周五 23:34写道:
… Can you tell me more about your setup. Do you use a second monitor? Do you
have a retina display?
I'm still wondering how exactly the screen capture works on macOS. The way
you explained the problem, it sounds like the region you select is not
actually the region the model gets to see.
I can't really do anything about that at the moment, because I don't have
a mac book.
If you want you can find the gui.py file and add img.show() in line 300
to see what the model will see.
https://github.com/lukas-blecher/LaTeX-OCR/blob/main/pix2tex/gui.py#L300
like this:
img = ImageGrab.grab(bbox=(x1//factor, y1//factor, x2//factor, y2//factor), all_screens=True)
else:
raise e+ img.show()
QApplication.processEvents()
Possibly related #122
<#122> #118
<#118> #145
<#145>
—
Reply to this email directly, view it on GitHub
<#241 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHWNVSADOG344T3WPEUIKCTWX6K6XANCNFSM6AAAAAAU7RS6MU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
According to BoboTiG/python-mss#134, Grant screen record permission to the Terminal app (I use the Terminal app to run |
thank you! I met the same problem, and solved it according to your method. |
The pix2tex command line tool works really well for me, generating high quality results most of the time. But the GUI by calling latexocr gives completely random results.
E.g. when pix2tex generate$E=m c^{2}$ the GUI generate $\scriptstyle{\hat{s e}}_{k\in G a l}^{a=1,10}$
Environment: macOS 12.6.3, Python 3.7.7, PyQt5
PS, can you add option in pix2tex command line to automatically bracket with $$? Thanks!
The text was updated successfully, but these errors were encountered: