Skip to content

Commit

Permalink
Release 2.0
Browse files Browse the repository at this point in the history
1. 新增百度在线OCR识别引擎,支持通用版识别和高精度版识别,可以使用共享密钥和自己的私有密钥。如使用自己的私有密钥,需在设置中进行配置。
2. 新增黑屏检测功能,若当黑屏开启时进行OCR识别,将给出提示。
3. 去除安装时64位系统检测,但非64位系统安装后,仅能使用在线OCR识别而无法使用离线识别。
  • Loading branch information
huaiyinfeilong committed May 2, 2023
1 parent 90edaa0 commit 4cdd368
Show file tree
Hide file tree
Showing 165 changed files with 9,904 additions and 20,200 deletions.
15 changes: 11 additions & 4 deletions addon/doc/zh_CN/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# 新翼OCR

这是基于PaddleOCR_json离线OCR组件而开发的一个NVDA OCR识别插件
这是一个提供离线和在线OCR识别的NVDA插件。离线识别基于PaddleOCR_json组件而开发

本插件目前仅接入PaddleOCR_json的本地OCR识别引擎,安装插件后会自动安装PaddleOCR_json组件。后续会逐步接入其他离线、在线OCR识别引擎。
本插件目前提供PaddleOCR_json的离线OCR识别引擎和在线百度通用版、高精度版识别引擎,安装插件后会自动安装PaddleOCR_json组件。后续会逐步接入更多的其他离线、在线OCR识别引擎。

## 插件优点

* 识别速度快,大约100ms左右,实际情况因计算机性能配置而异。
* 强悍的识别准确度,媲美在线识别。
* 识别速度快,离线识别大约100ms左右,实际情况因计算机性能配置而异。
* 强悍的离线识别准确度,媲美在线识别。
* 识别结果文字坐标精准,结果文字点击响应准确。

## 键盘快捷键

* 导航对象识别:NVDA+ALT+O
* 剪贴板识别:NVDA+ALT+SHIFT+O
* 切换识别引擎:NVDA+ALT+9

快捷键设置:可在“按键与手势”设置中针对“新翼OCR”分类下各命令设置快捷键。

Expand All @@ -28,6 +29,12 @@

## 升级日志

### Version 2.0

* 新增百度在线OCR识别引擎,支持通用版识别和高精度版识别,可以使用共享密钥和自己的私有密钥。如使用自己的私有密钥,需在设置中进行配置。
* 新增黑屏检测功能,若当黑屏开启时进行OCR识别,将给出提示。
* 去除安装时64位系统检测,但非64位系统安装后,仅能使用在线OCR识别而无法使用离线识别。

### Version 1.3

* 修复在NVDA2023.1以下版本无法安装的问题。
Expand Down
42 changes: 25 additions & 17 deletions addon/globalPlugins/_py3_contrib/PIL/BdfFontFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
# See the README file for information on usage and redistribution.
#

from __future__ import print_function
"""
Parse X Bitmap Distribution Format (BDF)
"""

from . import FontFile, Image

# --------------------------------------------------------------------
# parse X Bitmap Distribution Format (BDF)
# --------------------------------------------------------------------
from . import FontFile, Image

bdf_slant = {
"R": "Roman",
Expand Down Expand Up @@ -65,32 +64,41 @@ def bdf_char(f):
bitmap.append(s[:-1])
bitmap = b"".join(bitmap)

[x, y, l, d] = [int(p) for p in props["BBX"].split()]
[dx, dy] = [int(p) for p in props["DWIDTH"].split()]
# The word BBX
# followed by the width in x (BBw), height in y (BBh),
# and x and y displacement (BBxoff0, BByoff0)
# of the lower left corner from the origin of the character.
width, height, x_disp, y_disp = [int(p) for p in props["BBX"].split()]

bbox = (dx, dy), (l, -d - y, x + l, -d), (0, 0, x, y)
# The word DWIDTH
# followed by the width in x and y of the character in device pixels.
dwx, dwy = [int(p) for p in props["DWIDTH"].split()]

bbox = (
(dwx, dwy),
(x_disp, -y_disp - height, width + x_disp, -y_disp),
(0, 0, width, height),
)

try:
im = Image.frombytes("1", (x, y), bitmap, "hex", "1")
im = Image.frombytes("1", (width, height), bitmap, "hex", "1")
except ValueError:
# deal with zero-width characters
im = Image.new("1", (x, y))
im = Image.new("1", (width, height))

return id, int(props["ENCODING"]), bbox, im


##
# Font file plugin for the X11 BDF format.


class BdfFontFile(FontFile.FontFile):
def __init__(self, fp):
"""Font file plugin for the X11 BDF format."""

FontFile.FontFile.__init__(self)
def __init__(self, fp):
super().__init__()

s = fp.readline()
if s[:13] != b"STARTFONT 2.1":
raise SyntaxError("not a valid BDF file")
msg = "not a valid BDF file"
raise SyntaxError(msg)

props = {}
comments = []
Expand Down
Loading

0 comments on commit 4cdd368

Please sign in to comment.