dynobo / normcap

OCR powered screen-capture tool to capture information instead of images

Home Page:https://dynobo.github.io/normcap/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Screenshots are saved in /home/Pictures with every OCR

sojusnik opened this issue · comments

What happened?

Every time an OCR is performed, the screenshot of the whole desktop on which the OCR was performed is saved under /home/Pictures.

Ideally, no screenshots should be saved at all when doing an OCR.

How did you install NormCap?

FlatPak (Linux)

Operating System + Version?

Ubuntu 23.04

[Linux only] Display Server (DS) + Desktop environment (DE)?

DS: Wayland DE: Gnome 45.2

Debug log output?*

$ flatpak run --command=normcap com.github.dynobo.normcap -v debug
14:50:15 - INFO    - normcap:49 - Start NormCap v0.5.4
14:50:15 - DEBUG   - normcap:100 - Set QT_QPA_PLATFORM=wayland
14:50:15 - DEBUG   - normcap.gui.tray:77 - System info:
{'normcap_version': '0.5.4', 'python_version': '3.11.5', 'cli_args': '/app/bin/normcap -v debug', 'is_briefcase_package': False, 'is_flatpak_package': True, 'is_appimage_package': False, 'platform': 'linux', 'desktop_environment': <DesktopEnvironment.GNOME: 1>, 'display_manager_is_wayland': True, 'pyside6_version': '6.6.1', 'qt_version': '6.6.1', 'qt_library_path': '/usr/share/runtime/lib/plugins, /app/lib/python3.11/site-packages/PySide6/Qt/plugins, /usr/bin', 'locale': 'de_DE', 'config_directory': PosixPath('/home/sojusnik/.var/app/com.github.dynobo.normcap/config/normcap'), 'resources_path': PosixPath('/app/lib/python3.11/site-packages/normcap/resources'), 'tesseract_path': PosixPath('/app/bin/tesseract'), 'tessdata_path': PosixPath('/home/sojusnik/.var/app/com.github.dynobo.normcap/config/normcap/tessdata'), 'envs': {'TESSDATA_PREFIX': '/app/share', 'LD_LIBRARY_PATH': ''}, 'screens': [Screen(left=0, top=0, right=1919, bottom=1079, device_pixel_ratio=1.0, index=0, screenshot=None)]}
14:50:15 - DEBUG   - normcap.gui.settings:162 - Skip update of non existing setting (show_introduction: None)
14:50:15 - DEBUG   - normcap.gui.settings:162 - Skip update of non existing setting (cli_mode: False)
14:50:15 - DEBUG   - normcap.gui.settings:162 - Skip update of non existing setting (background_mode: False)
14:50:15 - DEBUG   - normcap.gui.settings:162 - Skip update of non existing setting (clipboard_handler: None)
14:50:15 - DEBUG   - normcap.gui.tray:388 - Listen on local socket v0.5.4-normcap.
14:50:15 - DEBUG   - normcap.screengrab.main:32 - Select capture method DBUS portal
14:50:15 - DEBUG   - normcap.screengrab.dbus_portal:94 - DBus request message: <PySide6.QtDBus.QDBusMessage(type=MethodReturn, service=":1.86", signature="o", contents=([ObjectPath: /org/freedesktop/portal/desktop/request/1_667/normcap_gdiigifg]) ) at 0x72dc7eb94200>
14:50:15 - DEBUG   - normcap.screengrab.dbus_portal:101 - Request accepted
14:50:15 - DEBUG   - normcap.ocr.tesseract:24 - Executing '/app/bin/tesseract --list-langs --tessdata-dir /home/sojusnik/.var/app/com.github.dynobo.normcap/config/normcap/tessdata'
14:50:15 - DEBUG   - normcap.ocr.tesseract:37 - Tesseract command output: List of available languages in "/home/sojusnik/.var/app/com.github.dynobo.normcap/config/normcap/tessdata/" (3): ¬ deu ¬ eng ¬ rus ¬
14:50:16 - DEBUG   - normcap.screengrab.dbus_portal:121 - DBus signal message: <PySide6.QtDBus.QDBusMessage(type=Signal, service=":1.86", path="/org/freedesktop/portal/desktop/request/1_667/normcap_gdiigifg", interface="org.freedesktop.portal.Request", member="Response", signature="ua{sv}", contents=(0, [Argument: a{sv} {"uri" = [Variant(QString): "file:///run/user/1000/doc/61150044/Screenshot.png"]}]) ) at 0x72dc7ee25e80>
14:50:16 - DEBUG   - normcap.screengrab.dbus_portal:139 - Parse response
14:50:16 - DEBUG   - normcap.screengrab.utils:25 - Virtual geometry width: 1920
14:50:16 - DEBUG   - normcap.screengrab.utils:26 - Image width: 1920
14:50:16 - DEBUG   - normcap.screengrab.utils:27 - Resize ratio: 1.0
14:50:16 - DEBUG   - normcap.gui.utils:22 - Save debug image as /tmp/normcap/2024-01-24_13-50-16_raw_screen0.png
14:50:16 - DEBUG   - normcap.gui.window:52 - Create window for screen 0
14:50:16 - DEBUG   - normcap.gui.window:128 - Set window of screen 0 to fullscreen
14:50:16 - DEBUG   - normcap.gui.dbus:177 - Moving window 'NormCap [0]' to (left=0, top=0, right=1919, bottom=1079) via org.gnome.Shell.extensions.windows
14:50:16 - WARNING - normcap.gui.dbus:205 - Failed to move window via org.gnome.Shell.extensions.windows!
14:50:16 - DEBUG   - normcap.gui.dbus:206 - Traceback (most recent call last):
  File "/app/lib/python3.11/site-packages/normcap/gui/dbus.py", line 186, in move_windows_via_window_calls_extension
    response = proxy.list_()
               ^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/jeepney/io/blocking.py", line 279, in inner
    return unwrap_msg(self._connection.send_and_get_reply(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/jeepney/wrappers.py", line 214, in unwrap_msg
    raise DBusErrorResponse(msg)
jeepney.wrappers.DBusErrorResponse: [org.freedesktop.DBus.Error.ServiceUnknown] ('org.freedesktop.DBus.Error.ServiceUnknown',)
14:50:16 - WARNING - normcap.gui.dbus:207 - If you experience issues with NormCap's in a multi monitor setting, try installing the Gnome Shell Extension 'Window Calls' from https://extensions.gnome.org/extension/4724/window-calls/
14:50:16 - DEBUG   - normcap.gui.dbus:81 - Moving window 'NormCap [0]' to (left=0, top=0, right=1919, bottom=1079) via org.gnome.Shell.Eval
14:50:16 - WARNING - normcap.gui.dbus:106 - Failed to move window via org.gnome.Shell.Eval!
14:50:16 - DEBUG   - normcap.gui.dbus:107 - Traceback (most recent call last):
  File "/app/lib/python3.11/site-packages/normcap/gui/dbus.py", line 102, in move_window_via_gnome_shell_eval
    response = proxy.eval_(script=js_code)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/jeepney/io/blocking.py", line 279, in inner
    return unwrap_msg(self._connection.send_and_get_reply(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/jeepney/wrappers.py", line 214, in unwrap_msg
    raise DBusErrorResponse(msg)
jeepney.wrappers.DBusErrorResponse: [org.freedesktop.DBus.Error.ServiceUnknown] ('org.freedesktop.DBus.Error.ServiceUnknown',)
14:50:21 - DEBUG   - normcap.gui.tray:354 - Hide 1 window
14:50:21 - INFO    - normcap.gui.tray:246 - Crop image to region (647, 490, 874, 577)
14:50:21 - DEBUG   - normcap.gui.utils:22 - Save debug image as /tmp/normcap/2024-01-24_13-50-21_cropped.png
14:50:21 - DEBUG   - normcap.gui.tray:271 - Start OCR
14:50:21 - DEBUG   - normcap.ocr.enhance:84 - Scale image x2
14:50:21 - DEBUG   - normcap.ocr.enhance:57 - Pad image by 80px
14:50:21 - DEBUG   - normcap.ocr.recognize:35 - Run Tesseract on image of size (616, 336) with args:
TessArgs(tessdata_path=PosixPath('/home/sojusnik/.var/app/com.github.dynobo.normcap/config/normcap/tessdata'), lang='deu+eng+rus', oem=<OEM.DEFAULT: 3>, psm=<PSM.AUTO: 3>)
14:50:21 - DEBUG   - normcap.ocr.tesseract:24 - Executing '/app/bin/tesseract /tmp/tmplr3weyf2/normcap_tesseract_input.png /tmp/tmplr3weyf2/normcap_tesseract_input.png -c tessedit_create_tsv=1 -l deu+eng+rus --oem 3 --psm 3 --tessdata-dir /home/sojusnik/.var/app/com.github.dynobo.normcap/config/normcap/tessdata -c tessedit_write_images=1 -c tessedit_dump_pageseg_images=1'
14:50:22 - DEBUG   - normcap.ocr.tesseract:37 - Tesseract command output: 
14:50:22 - DEBUG   - normcap.ocr.tesseract:67 - Skip moving file to temp dir, it does not exist: /tmp/tmplr3weyf2/normcap_tesseract_input.png.png_debug.pdf
14:50:22 - DEBUG   - normcap.ocr.recognize:44 - OCR result:
OcrResult(tess_args=TessArgs(tessdata_path=PosixPath('/home/sojusnik/.var/app/com.github.dynobo.normcap/config/normcap/tessdata'), lang='deu+eng+rus', oem=<OEM.DEFAULT: 3>, psm=<PSM.AUTO: 3>), words=[{'level': 5, 'page_num': 1, 'block_num': 1, 'par_num': 1, 'line_num': 1, 'word_num': 1, 'left': 94, 'top': 100, 'width': 370, 'height': 28, 'conf': 89.638321, 'text': 'normcap.gui.settings:'}, {'level': 5, 'page_num': 1, 'block_num': 1, 'par_num': 1, 'line_num': 2, 'word_num': 1, 'left': 94, 'top': 138, 'width': 370, 'height': 28, 'conf': 89.638321, 'text': 'normcap.gui.settings:'}, {'level': 5, 'page_num': 1, 'block_num': 1, 'par_num': 1, 'line_num': 3, 'word_num': 1, 'left': 94, 'top': 176, 'width': 370, 'height': 28, 'conf': 89.638321, 'text': 'normcap.gui.settings:'}, {'level': 5, 'page_num': 1, 'block_num': 1, 'par_num': 1, 'line_num': 4, 'word_num': 1, 'left': 94, 'top': 214, 'width': 370, 'height': 28, 'conf': 89.638321, 'text': 'normcap.gui.settings:'}, {'level': 5, 'page_num': 1, 'block_num': 2, 'par_num': 1, 'line_num': 1, 'word_num': 1, 'left': 472, 'top': 102, 'width': 50, 'height': 20, 'conf': 96.692459, 'text': '162'}, {'level': 5, 'page_num': 1, 'block_num': 2, 'par_num': 1, 'line_num': 2, 'word_num': 1, 'left': 472, 'top': 140, 'width': 50, 'height': 20, 'conf': 96.692459, 'text': '162'}, {'level': 5, 'page_num': 1, 'block_num': 2, 'par_num': 1, 'line_num': 3, 'word_num': 1, 'left': 472, 'top': 178, 'width': 50, 'height': 20, 'conf': 96.692459, 'text': '162'}, {'level': 5, 'page_num': 1, 'block_num': 2, 'par_num': 1, 'line_num': 4, 'word_num': 1, 'left': 472, 'top': 216, 'width': 50, 'height': 20, 'conf': 96.692459, 'text': '162'}], image=<PySide6.QtGui.QImage(QSize(616, 336),format=QImage::Format_RGB32,depth=32,devicePixelRatio=1,bytesPerLine=2464,sizeInBytes=827904) at 0x72dc7eb95640>, magic_scores={}, parsed='')
14:50:22 - INFO    - normcap.ocr.magics.email_magic:60 - 0 emails found 
14:50:22 - DEBUG   - normcap.ocr.magics.email_magic:71 - 0/96 (0.0) chars in emails
14:50:22 - INFO    - normcap.ocr.magics.url_magic:57 - 0 URLs found 
14:50:22 - DEBUG   - normcap.ocr.magics.url_magic:65 - 0/104 (0.0) chars in urls
14:50:22 - DEBUG   - normcap.ocr.magic:82 - Magic scores:
{'SingleLineMagic': 0, 'MultiLineMagic': 0, 'ParagraphMagic': 50.0, 'EmailMagic': 0.0, 'UrlMagic': 0.0}
14:50:22 - DEBUG   - normcap.ocr.recognize:48 - Parsed text:
normcap.gui.settings: normcap.gui.settings: normcap.gui.settings: normcap.gui.settings:
162 162 162 162
14:50:22 - DEBUG   - normcap.gui.utils:22 - Save debug image as /tmp/normcap/2024-01-24_13-50-22_enhanced.png
14:50:22 - INFO    - normcap.gui.tray:289 - Text from OCR:
normcap.gui.settings: normcap.gui.settings: normcap.gui.settings: normcap.gui.settings:
162 162 162 162
14:50:22 - DEBUG   - normcap.gui.tray:332 - Copy text to clipboard
14:50:22 - DEBUG   - normcap.clipboard.handlers.windll:187 - WindllHandler is incompatible on non-Windows systems
14:50:22 - DEBUG   - normcap.clipboard.handlers.pbcopy:24 - PbCopyHandler is incompatible on non-macOS systems
14:50:22 - DEBUG   - normcap.clipboard.handlers.qtclipboard:31 - QtCopyHandler is not compatible with Wayland
14:50:22 - DEBUG   - normcap.clipboard.handlers.wlclipboard:49 - WlCopyHandler is compatible
14:50:22 - DEBUG   - normcap.clipboard.handlers.xclip:38 - XclipCopyHandler is compatible
14:50:22 - DEBUG   - normcap.clipboard.main:84 - Compatible clipboard handlers: ['wlclipboard', 'xclip']
14:50:22 - DEBUG   - normcap.clipboard.handlers.wlclipboard:57 - WlCopyHandler dependencies are installed (/app/bin/wl-copy)
14:50:22 - DEBUG   - normcap.clipboard.handlers.xclip:43 - XclipCopyHandler is not installed: xclip was not found
14:50:22 - DEBUG   - normcap.clipboard.main:89 - Available clipboard handlers: ['wlclipboard']
14:50:22 - DEBUG   - normcap.clipboard.handlers.wlclipboard:49 - WlCopyHandler is compatible
14:50:22 - DEBUG   - normcap.clipboard.main:56 - Text copied to clipboard using 'wlclipboard.' handler

Yes I always have to clean out my Pictures folder, @dynobo please fix this.

I can confirm this issue and I also don't like this behavior. It would be nice if it used a directory like /tmp or something by default, if it can't be done differently.

Should be fixed in the latest release 0.5.7.
It would be nice if you could report back, if it works for you (screenshots are being deleted).

Should be fixed in the latest release 0.5.7. It would be nice if you could report back, if it works for you (screenshots are being deleted).

It is fixed indeed, thank you so much!