dynobo / normcap

OCR powered screen-capture tool to capture information instead of images
https://dynobo.github.io/normcap/
Other
1.9k stars 89 forks source link

Zoomed desktop shown in Ubuntu 22.04.1 LTS #273

Closed ikesaber closed 2 years ago

ikesaber commented 2 years ago

Issue with NormCap in Ubuntu 22.04.1 LTS

Hello, I recently installed Ubuntu 22.04.1 (old OS was 22.04), and I can't get NormCap to work properly on my new OS.

AppImage

In Focal Fossa, normcap worked as shown in your gif:

gif

When I run the appimage in Jammy Jellyfish, the screenshot is zoomed 3x and off to the side (Below is a screenshot of my entire screen). 

image

Python package

I wanted to see if the python package would work better so I installed the package with sudo apt install build-essential tesseract-ocr tesseract-ocr-eng libtesseract-dev libleptonica-dev wl-clipboard && pip install normcap; but i'm not sure how to run it. Running pip show normcap says the app is in /home/user/anaconda3/lib/python3.9/site-packages but when I try /home/user/anaconda3/lib/python3.9/site-packages/normcap, bash tells me it's a directory.

Can you help me sort all this out?

dynobo commented 2 years ago

Hi @ikesaber,

Starting the Python package: After pip install normcap ran through, you should be able to start NormCap just by typing the command normcap in the terminal. (But I don't think this will help with the zooming issue)

Screenshot is zoomed: This is probably a bug, can you please provide some additional info? That would help me to sort it out:

  1. Please start NormCap in debug mode and post the output: ./NormCap-0.3.12-x86_64.AppImage -v debug
  2. Can you provide me some information about your monitor setup?
    • How many monitors do you have?
    • What is their resolution?"
    • Do you use "scaling"? (Is "scale" in the display settings something different from "100%"?)

Some background: On focal, you were probably running in "Xorg" mode (that was the default back then), while in jammy you are probably running "Wayland" mode. You can verify that by executing echo $XDG_SESSION_TYPE. Wayland has some great feature, e.g. fractional scaling and better HiDPI support, but it's harder for NormCap to determine (and show) the screenshot in the correct screen resolution. It seems like that logic fails for your setup.

Let's see, if I can fix it with enough information! :-)

PS: If a working NormCap is important for you, you can also try switching temporarily to X, but I'd prefer if we could fix the issue under wayland.

ikesaber commented 2 years ago

Thank you for your reply @dynobo

It looks like completely forgetting about this for a week and then coming back to it has fixed my problem 🤨 - I can now use normcap as before with no zoom issue. However I went through the steps you recommended anyway:

After pip install normcap ran through, you should be able to start NormCap just by typing the command normcap in the terminal. (But I don't think this will help with the zooming issue)

interesting... this is what happens when I try that:

(base) user@computer:~$ pip install normcap
Requirement already satisfied: normcap in ./anaconda3/lib/python3.9/site-packages (0.3.12)
Requirement already satisfied: jeepney>=0.8 in ./anaconda3/lib/python3.9/site-packages (from normcap) (0.8.0)
Requirement already satisfied: pytesseract>=0.3.10 in ./anaconda3/lib/python3.9/site-packages (from normcap) (0.3.10)
Requirement already satisfied: certifi<2023.0.0,>=2022.6.15 in ./anaconda3/lib/python3.9/site-packages (from normcap) (2022.9.14)
Requirement already satisfied: packaging>=21.3 in ./anaconda3/lib/python3.9/site-packages (from normcap) (21.3)
Requirement already satisfied: PySide6-Essentials<7.0.0,>=6.3.1 in ./anaconda3/lib/python3.9/site-packages (from normcap) (6.3.2)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in ./anaconda3/lib/python3.9/site-packages (from packaging>=21.3->normcap) (3.0.4)
Requirement already satisfied: shiboken6==6.3.2 in ./anaconda3/lib/python3.9/site-packages (from PySide6-Essentials<7.0.0,>=6.3.1->normcap) (6.3.2)
Requirement already satisfied: Pillow>=8.0.0 in ./anaconda3/lib/python3.9/site-packages (from pytesseract>=0.3.10->normcap) (8.4.0)
(base) user@computer:~$ normcap
01:25:50 - ERROR   - normcap.gui.utils:56 - [QT] qtfatalmsg - this application failed to start because no qt platform plugin could be initialized. reinstalling the application may fix this problem.

Aborted (core dumped)

Please start NormCap in debug mode and post the output: ./NormCap-0.3.12-x86_64.AppImage -v debug

here is my terminal output:


(base) user@computer:~/.local/share/applications/AppImages$ ./NormCap-0.3.12-x86_64.AppImage -v debug
01:30:39 - INFO    - normcap:36 - Start NormCap v0.3.12
01:30:39 - DEBUG   - normcap:57 - System info:
{'cli_args': '/tmp/.mount_NormCacskrCO/usr/app/normcap/__main__.py -v debug', 'is_prebuild_package': 'briefcase', 'is_flatpak_package': False, 'platform': 'linux', 'pyside6_version': '6.2.4', 'qt_version': '6.2.4', 'qt_library_path': '/tmp/.mount_NormCacskrCO/usr/app_packages/PySide6/Qt/plugins, /tmp/.mount_NormCacskrCO/usr/bin', 'config_directory': PosixPath('/home/user/.config/normcap'), 'normcap_version': '0.3.12', 'tessdata_path': '/home/user/.config/normcap/tessdata', 'envs': {'TESSERACT_CMD': '/tmp/.mount_NormCacskrCO/usr/bin/tesseract', 'TESSERACT_VERSION': None, 'TESSDATA_PREFIX': None, 'LD_LIBRARY_PATH': None}, 'desktop_environment': <DesktopEnvironment.GNOME: 1>, 'display_manager_is_wayland': False, 'gnome_version': <Version('42.4')>, 'screens': {0: Screen(is_primary=True, device_pixel_ratio=2.0, geometry=Rect(left=0, top=0, right=1920, bottom=1080), index=0, screenshot=None), 1: Screen(is_primary=False, device_pixel_ratio=2.0, geometry=Rect(left=3840, top=0, right=4380, bottom=960), index=1, screenshot=None)}}
01:30:39 - DEBUG   - normcap.gui.tray:49 - Set up tray icon
01:30:39 - DEBUG   - normcap.clipboard.linux:42 - Use Qt to copy to clipboard.
01:30:39 - DEBUG   - normcap.screengrab.qt:15 - Use capture method: QT
01:30:39 - DEBUG   - normcap.gui.utils:44 - Store debug image in: /tmp/normcap/2022-09-22_01-30-39_569953_raw_screen0.png
01:30:40 - DEBUG   - normcap.gui.utils:44 - Store debug image in: /tmp/normcap/2022-09-22_01-30-39_970964_raw_screen1.png
01:30:40 - DEBUG   - normcap.gui.window:51 - Create window for screen 0
01:30:40 - DEBUG   - normcap.gui.window:199 - Set window for screen 0 to fullscreen
01:30:40 - DEBUG   - normcap.gui.window:51 - Create window for screen 1
01:30:40 - DEBUG   - normcap.gui.window:199 - Set window for screen 1 to fullscreen
01:30:40 - DEBUG   - normcap.gui.update_check:68 - Search for new version on https://github.com/dynobo/normcap/releases
01:30:40 - DEBUG   - normcap.gui.downloader_urllib:32 - Download https://github.com/dynobo/normcap/releases
01:30:40 - ERROR   - normcap.gui.update_check:61 - Couldn't parse newest version! Update check won't work!
01:30:44 - DEBUG   - normcap.gui.tray:270 - Hide 2 window(s)
01:30:44 - INFO    - normcap.gui.tray:195 - Crop image to selected region (2346, 504, 2426, 564)
01:30:44 - DEBUG   - normcap.gui.utils:44 - Store debug image in: /tmp/normcap/2022-09-22_01-30-44_437326_cropped.png
01:30:44 - DEBUG   - normcap.gui.tray:227 - Start OCR
01:30:44 - DEBUG   - normcap.ocr.enhance:54 - Resize screenshot by factor 3.2
01:30:44 - DEBUG   - normcap.ocr.enhance:36 - Pad image by 80 px
01:30:44 - DEBUG   - normcap.ocr.enhance:73 - Inverting screenshot
01:30:44 - DEBUG   - normcap.ocr.recognize:37 - Init tesseract with args: TessArgs(path='/home/user/.config/normcap/tessdata', lang='eng', oem=<OEM.DEFAULT: 3>, psm=<PSM.AUTO_OSD: 1>, version=<Version('4.0.0')>)
01:30:44 - DEBUG   - normcap.ocr.recognize:38 - Image size: (416, 352)
01:30:44 - DEBUG   - normcap.ocr.recognize:51 - OCR result: OcrResult(tess_args=TessArgs(path='/home/user/.config/normcap/tessdata', lang='eng', oem=<OEM.DEFAULT: 3>, psm=<PSM.AUTO_OSD: 1>, version=<Version('4.0.0')>), words=[{'level': 5, 'page_num': 1, 'block_num': 1, 'par_num': 1, 'line_num': 1, 'word_num': 1, 'left': 80, 'top': 123, 'width': 220, 'height': 126, 'conf': 76, 'text': 'Tip'}], image=<PIL.Image.Image image mode=RGB size=416x352 at 0x7FC695566440>, magic_scores={}, transformed='')
01:30:44 - INFO    - normcap.ocr.magics.email_magic:34 - 0 emails found ['']
01:30:44 - DEBUG   - normcap.ocr.magics.email_magic:45 - 0/3 chars in emails. Ratio: 0.0)
01:30:44 - INFO    - normcap.ocr.magics.url_magic:54 - 0 URLs found ['']
01:30:44 - DEBUG   - normcap.ocr.magics.url_magic:64 - 0 of 3 chars in urls (ratio: 0.0)
01:30:44 - DEBUG   - normcap.ocr.magics.magic:74 - All scores: {'SingleLineMagic': 50, 'MultiLineMagic': 0, 'ParagraphMagic': 0.0, 'EmailMagic': 0.0, 'UrlMagic': 0.0}
01:30:44 - DEBUG   - normcap.ocr.recognize:55 - Transformed text: Tip
01:30:44 - DEBUG   - normcap.gui.utils:44 - Store debug image in: /tmp/normcap/2022-09-22_01-30-44_817844_enhanced.png
01:30:44 - INFO    - normcap.gui.tray:241 - Text from OCR:
Tip
01:30:44 - DEBUG   - normcap.gui.tray:293 - Path to debug images: /tmp/normcap
01:30:44 - INFO    - normcap.gui.tray:294 - Exit normcap (reason: detection completed)

Some background: On focal, you were probably running in "Xorg" mode (that was the default back then), while in jammy you are probably running "Wayland" mode. You can verify that by executing echo $XDG_SESSION_TYPE.

(base) user@computer:~/.local/share/applications/AppImages$ echo $XDG_SESSION_TYPE
x11
dynobo commented 2 years ago

Thanks for providing your additional info, @ikesaber !

Regarding the zoom-issue: Hard to say, what the problem caused, but "Wayland" can be ruled out, as you are clearly using Xorg session. Might it be, that you changed monitor setup while NormCap was running (e.g. in tray)? Like plugging in another monitor, changing the display resolution or something? I could imagine, that could mess things up. Nevertheless, I'm glad it's working for you again. And will close this issue. Feel free to re-open, when the issue comes back! :-)

Regarding Python package:

  1. I was able to reproduce your issues in a VM. When I installed NormCap inside the base-environment of anaconda, I got the exact same error. Using a different environment worked:

    $ conda env create -n myenv python=3.9
    $ conda activate myenv
    (myenv) $ pip install normcap
    (myenv) $ normcap -v debug

    I'm not super familiar with anaconda, but AFAIK, using the base environment is usually not a good idea anyway.

  2. I also notice that when doing pip install normcap in Ubuntu's Python environment (without Anaconda, or after doing conda deactivate) it will get installed to ~/.local/bin/normcap. But ~/.local/bin doesn't seem to be in Ubuntu's PATH by default, so just running normcap will result in command not found. You either have to add ~/.local/bin to your PATH or execute NormCap using the full path

    $ ~/.local/bin/normcap

I hope this helps! :-)

ikesaber commented 2 years ago

The monitor setup didn't affect the zooming problem before - the screenshot was taken while my computer had no monitors connected and it was the same when I plugged one in. I'd guess some system / app update(s) over the past week took care of the issue.

conda deactivate did allow me to use normcap through the terminal, so I'll keep that in mind for future reference.