New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

owocr

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

owocr - pypi Package Compare versions

Comparing version
1.26.7
to
1.26.8
+0
-8
ndlocr_lite/ocr_api.py

@@ -150,5 +150,2 @@ import sys

alllineobj = []
tatelinecnt = 0
alllinecnt = 0
for idx, lineobj in enumerate(root.findall(".//LINE")):

@@ -159,4 +156,2 @@ xmin, ymin = int(lineobj.get("X")), int(lineobj.get("Y"))

pred_char_cnt = float(lineobj.get("PRED_CHAR_CNT", 100.0))
if line_h > line_w: tatelinecnt += 1
alllinecnt += 1

@@ -186,5 +181,2 @@ # Crop image slice

if line_h > line_w: tatelinecnt += 1
alllinecnt += 1
lineimg = img[int(ymin):int(ymax), int(xmin):int(xmax), :]

@@ -191,0 +183,0 @@ alllineobj.append(RecogLine(lineimg, idx, pred_char_cnt))

+2
-2
Metadata-Version: 2.4
Name: owocr
Version: 1.26.7
Version: 1.26.8
Summary: Multi-service, multi-platform optical character recognition

@@ -46,3 +46,2 @@ Author-email: AuroraWright <fallingluma@gmail.com>

Requires-Dist: PyGObject; platform_system == "Linux"
Requires-Dist: dbus-python; platform_system == "Linux"
Requires-Dist: pywayland; platform_system == "Linux"

@@ -214,1 +213,2 @@ Provides-Extra: faster-png

- [kamperemu](https://github.com/kamperemu) for the OBS source implementation!
- [KamWithK](https://github.com/KamWithK) and [Manhhao](https://github.com/Manhhao) for improving the Wayland mss shim to not require python-dbus and for session persistence

@@ -20,3 +20,2 @@ jaconv

PyGObject
dbus-python
pywayland

@@ -23,0 +22,0 @@

@@ -1,2 +0,2 @@

__version__ = (1, 26, 7)
__version__ = (1, 26, 8)
__version_string__ = '.'.join(map(str, __version__))

@@ -271,2 +271,3 @@ import configparser

('screen_capture_regex_filter', 'str', 'Regex filter for unwanted text'),
('screen_capture_wayland_persistence', 'bool', 'On Wayland, persist the session when owocr is restarted (ignored on other platforms)'),
],

@@ -273,0 +274,0 @@ 'OBS': [

@@ -63,2 +63,4 @@ import os

help='When reading with screen capture or obs, regex to filter unwanted text from the output. Example value: ▶|♥|・ to remove either of those characters.')
parser.add_argument('-swp', '--screen_capture_wayland_persistence', type=str2bool, nargs='?', const=True, default=argparse.SUPPRESS,
help='When reading with screen capture on Wayland, persist the session when owocr is restarted. Has no effect on other platforms.')
parser.add_argument('-sc', '--screen_capture_combo', type=str, default=argparse.SUPPRESS,

@@ -142,2 +144,3 @@ help='When reading with screen capture or obs, combo to wait on for taking a screenshot. If periodic screenshots are also enabled, any screenshot taken this way bypasses the filtering. Example value: <ctrl>+<shift>+s. The list of keys can be found here: https://pynput.readthedocs.io/en/latest/keyboard.html#pynput.keyboard.Key')

'screen_capture_regex_filter': '',
'screen_capture_wayland_persistence': False,
'join_lines': False,

@@ -144,0 +147,0 @@ 'join_paragraphs': False,

@@ -5,10 +5,9 @@ import re

import time
import uuid
from pathlib import Path
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GLib, Gst
from gi.repository import GLib, Gst, Gio
import dbus
from dbus.mainloop.glib import DBusGMainLoop
import mss as real_mss

@@ -19,2 +18,4 @@ from mss.exception import ScreenShotError

from .config import config
screencast = None

@@ -26,2 +27,3 @@ screencast_lock = threading.Lock()

def __init__(self):
self.token_file_path = Path.home() / '.cache' / '.owocr_screencapture_token'
self.screen_cast_iface = 'org.freedesktop.portal.ScreenCast'

@@ -50,18 +52,25 @@ self.frame_lock = threading.Lock()

def _screen_cast_call(self, method, callback, *args, options=None):
if options is None:
options = {}
request_path, request_token = self._new_request_path()
def _screen_cast_call(self, method, request_path, callback, variant):
self.bus.signal_subscribe(
'org.freedesktop.portal.Desktop',
'org.freedesktop.portal.Request',
'Response',
request_path,
None,
Gio.DBusSignalFlags.NO_MATCH_RULE,
callback,
)
self.bus.add_signal_receiver(
callback,
'Response',
'org.freedesktop.portal.Request',
self.bus.call_sync(
'org.freedesktop.portal.Desktop',
request_path
'/org/freedesktop/portal/desktop',
self.screen_cast_iface,
method,
variant,
None,
Gio.DBusCallFlags.NONE,
-1,
None,
)
options['handle_token'] = request_token
method(*(args + (options,)), dbus_interface=self.screen_cast_iface)
def _on_session_closed(self, *args, **kwargs):

@@ -108,15 +117,17 @@ self.stop()

def _play_pipewire_stream(self, node_id):
portal = self.bus.get_object(
result, out_fd_list = self.bus.call_with_unix_fd_list_sync(
'org.freedesktop.portal.Desktop',
'/org/freedesktop/portal/desktop'
'/org/freedesktop/portal/desktop',
self.screen_cast_iface,
'OpenPipeWireRemote',
GLib.Variant('(oa{sv})', (self.session, {})),
GLib.VariantType.new('(h)'),
Gio.DBusCallFlags.NONE,
-1,
None,
None,
)
fd_index = result.unpack()[0]
fd = out_fd_list.get(fd_index)
empty_dict = dbus.Dictionary(signature='sv')
fd_object = portal.OpenPipeWireRemote(
self.session,
empty_dict,
dbus_interface=self.screen_cast_iface
)
fd = fd_object.take()
pipeline_str = (

@@ -137,3 +148,4 @@ f'pipewiresrc fd={fd} path={node_id} ! '

def _on_start_response(self, response, results):
def _on_start_response(self, connection, sender, object_path, interface, signal, parameters):
response, results = parameters.unpack()
if response != 0:

@@ -145,2 +157,5 @@ self.stop()

if 'restore_token' in results:
with open(self.token_file_path, 'w') as f:
f.write(results['restore_token'])
if results['streams']:

@@ -153,3 +168,4 @@ node_id, stream_properties = results['streams'][0]

def _on_select_sources_response(self, response, results):
def _on_select_sources_response(self, connection, sender, object_path, interface, signal, parameters):
response, results = parameters.unpack()
if response != 0:

@@ -159,16 +175,19 @@ self.stop()

portal = self.bus.get_object(
'org.freedesktop.portal.Desktop',
'/org/freedesktop/portal/desktop'
)
request_path, request_token = self._new_request_path()
variant = GLib.Variant('(osa{sv})', (
self.session,
'',
{
'handle_token': GLib.Variant('s', request_token),
},
))
self._screen_cast_call(
portal.Start,
'Start',
request_path,
self._on_start_response,
self.session,
'',
options={'multiple': False, 'types': dbus.UInt32(1 | 2), 'framerate': dbus.UInt32(30)}
variant,
)
def _on_create_session_response(self, response, results):
def _on_create_session_response(self, connection, sender, object_path, interface, signal, parameters):
response, results = parameters.unpack()
if response != 0:

@@ -180,20 +199,38 @@ self.stop()

self.session_closed_signal = self.bus.add_signal_receiver(
self.bus.signal_subscribe(
'org.freedesktop.portal.Desktop',
'org.freedesktop.portal.Session',
'Closed',
self.session,
None,
Gio.DBusSignalFlags.NONE,
self._on_session_closed,
'Closed',
'org.freedesktop.portal.Session',
'org.freedesktop.portal.Desktop',
self.session
)
portal = self.bus.get_object(
'org.freedesktop.portal.Desktop',
'/org/freedesktop/portal/desktop'
)
request_path, request_token = self._new_request_path()
restore_token = str(uuid.UUID(int=0))
if config.get_general('screen_capture_wayland_persistence'):
persist_mode = 2
if self.token_file_path.exists():
with open(self.token_file_path, 'r') as f:
restore_token = f.read().strip()
else:
persist_mode = 0
if self.token_file_path.exists():
self.token_file_path.unlink()
variant = GLib.Variant('(oa{sv})', (
self.session,
{
'handle_token': GLib.Variant('s', request_token),
'multiple': GLib.Variant('b', False),
'types': GLib.Variant('u', 1 | 2),
'persist_mode': GLib.Variant('u', persist_mode),
'restore_token': GLib.Variant('s', restore_token)
},
))
self._screen_cast_call(
portal.SelectSources,
'SelectSources',
request_path,
self._on_select_sources_response,
self.session,
options={'multiple': False, 'types': dbus.UInt32(1 | 2), 'framerate': dbus.UInt32(30)}
variant
)

@@ -203,20 +240,22 @@

Gst.init(None)
DBusGMainLoop(set_as_default=True)
self.bus = dbus.SessionBus()
self.sender_name = re.sub(r'\.', r'_', self.bus.get_unique_name()[1:])
context = GLib.MainContext.new()
context.push_thread_default()
try:
self.loop = GLib.MainLoop()
self.loop = GLib.MainLoop.new(context)
self.bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
self.sender_name = re.sub(r'\.', r'_', self.bus.get_unique_name()[1:])
portal = self.bus.get_object(
'org.freedesktop.portal.Desktop',
'/org/freedesktop/portal/desktop'
)
session_path, session_token = self._new_session_path()
request_path, request_token = self._new_request_path()
variant = GLib.Variant('(a{sv})', ({
'handle_token': GLib.Variant('s', request_token),
'session_handle_token': GLib.Variant('s', session_token),
},))
self._screen_cast_call(
portal.CreateSession,
'CreateSession',
request_path,
self._on_create_session_response,
options={'session_handle_token': session_token}
variant
)

@@ -228,2 +267,4 @@

raise ScreenShotError(f'Error initializing screencast: {e}')
finally:
context.pop_thread_default()

@@ -230,0 +271,0 @@ def request_frame(self):

Metadata-Version: 2.4
Name: owocr
Version: 1.26.7
Version: 1.26.8
Summary: Multi-service, multi-platform optical character recognition

@@ -46,3 +46,2 @@ Author-email: AuroraWright <fallingluma@gmail.com>

Requires-Dist: PyGObject; platform_system == "Linux"
Requires-Dist: dbus-python; platform_system == "Linux"
Requires-Dist: pywayland; platform_system == "Linux"

@@ -214,1 +213,2 @@ Provides-Extra: faster-png

- [kamperemu](https://github.com/kamperemu) for the OBS source implementation!
- [KamWithK](https://github.com/KamWithK) and [Manhhao](https://github.com/Manhhao) for improving the Wayland mss shim to not require python-dbus and for session persistence

@@ -57,3 +57,2 @@ [build-system]

"PyGObject;platform_system=='Linux'",
"dbus-python;platform_system=='Linux'",
"pywayland;platform_system=='Linux'",

@@ -60,0 +59,0 @@ ]

@@ -127,1 +127,2 @@ <div align="center">

- [kamperemu](https://github.com/kamperemu) for the OBS source implementation!
- [KamWithK](https://github.com/KamWithK) and [Manhhao](https://github.com/Manhhao) for improving the Wayland mss shim to not require python-dbus and for session persistence

Sorry, the diff of this file is too big to display