【GdOcrTool】即指即译,OCR取词工具

之前说错了,简体中文包要另外下载, chi_sim.traineddata

Capture2Text 还有个 portable 模式,可以弄个已经陪配置好后的ini文件覆盖,好像可以简化一些。

1. How do I make Capture2Text portable?

Call Capture2Text.exe using the --portable option. You may want to create a shortcut for this. Setting this option will make Capture2Text store the .ini settings file in same directory as Capture2Text.exe (as opposed to "%appdata%\Capture2Text" which is the normal location).

感觉行不通。它提供的命令行接口不是很完整,比如 Text Line Capture 和 Forward Text Line Capture 这两个最关键的功能就没有,只能通过快捷键唤起。

我理解错了。是可以弄个配置好的 ini 出来覆盖默认的。但默认 ini 所在的 AppData 文件夹是隐藏的,不熟悉电脑操作的人也不好弄。

portable模式下,ini就是在Capture2Text程序目录下的一个子目录中了。只是这样就要求程序启动时用 --portable 选项。

感谢 @Johnny_Van 越来越成熟了,正如我说的 “GoldenDict 官方版 OCR 功能增强”版包括“ 点选OCR ” 和 “ 框选OCR ”, “点选OCR”是其中的一大亮点!你用鼠标点一下图片,就立即显示GoldenDict的查询结果。大大方便了阅读体验!

我是直接copy/paste “Capture2Text.ini”的。

1 个赞

提示一下,如果需要对中文取词,还是不要浪费时间尝试这个了,中文识别效果很糟糕。可以试试 quicker 等。
另外,新版已上传,增加取词视觉反馈。

1 个赞

谢谢,刚刚试了。很好。能不能把弹出窗口位置 (不固定时)上下移动点,不要覆盖被OCR的那一行。目前要遮盖被OCR的单词。

可能是我画蛇添足了。删掉241行可去除框选提示,删掉110行去除点选提示,Tooltip…打头的行。

确实,有些问题其实没必要问的,为了维护一个良好的讨论环境,建议提问前先顺便学习下 How-To-Ask-Questions-The-Smart-Way

对不起,我没有说清楚。增加提示,很好的。我指的是词典弹出窗口, 见图。要查“settings”, 弹出窗口把“settings”所在的那行遮盖了。词典弹出窗口的位置根据情况,会在OCR的那一行的上面或者下面。如果能把弹出窗口位置 (不固定时)上下移动点,不要覆盖被OCR的那一行, 就perfect了。

查“settings”:

弹出窗口把“settings”所在的那行遮盖了:

希望是这样:

不会出现你说的情形:

1 个赞

@Vim 你再试一试?

我反复试了,弹出窗口在下面时经常(but not always)把“OCR”所在的那行遮盖了,但是弹出窗口在上面时,很多时候不会把“OCR”所在的那行遮盖。

当然,目前可以间接解决,即固定弹出窗口在其它位置。

GIF

取消固定窗口,即可解决。这属于GoldenDict的问题,不是GdOcrTool的问题。

@Vim It worked perfectly in your case. I do not know why I have that issue.

是的,GoldenDict有时没有把弹出窗口的位置计算好。

@Johnny_Van 想请教:为什么不用PaddleOCR,而是Capture2Text?Paddle号称可以中英文混合识别,效果还不错,也很小巧。

@Johnny_Van 纯粹是精益求精:可不可以当按ctrl和’键激活框选后,把mouse pointer在文字档时也变成“三角形”而不是“|”?

主要是方便框选定位。

改为十字型更佳

1 个赞

@Vim so it is doable. However, it is still beyond me. I just wait and hope @Johnny_Van will incorporate the codes in his OCR script.

我试着改了一下,把“ GdOcrTool_Cross.ahk”放在GoldenDict.exe所在目录,启动即可。

Updated 2021/11/25: 我把十字鼠标加入了 @Johnny_Van 最新的版本:

这里下载:GdOcrTool_Cross 2021-11-25.zip (3.2 KB)

按 ctrl和’ 键激活框选后,mouse pointer变成“+” (除了在Adobe Acrobat里), 按Esc(或者ctrl和q) 恢复原来的mouse pointer。

Updated 2021/11/21: 不能在Adobe Acrobat里改变mouse pointer,是因为Acrobat (reader) does not use the Windows System settings for their cursors. Therefore, you cannot change the cursors in Acrobat (reader) - neither color nor the icon can be changed. 好在,如果是图片pdf,Adobe Acrobat的mouse pointer会自动变成"+"形。

班门弄斧,很不成熟, 盼望 @Johnny_Van 出手定证。

具体改动如下

把下面的

^`::  ; Start box capture by pressing ctrl + `

换成:

^`::SetSystemCursor("IDC_CROSS")+BoxCapture()         ; Start box capture by pressing ctrl + `
^q::RestoreCursors()


SetSystemCursor( Cursor = "", cx = 0, cy = 0 )
{
	BlankCursor := 0, SystemCursor := 0, FileCursor := 0 ; init
	
	SystemCursors = 32512IDC_ARROW,32513IDC_IBEAM,32514IDC_WAIT,32515IDC_CROSS
	,32516IDC_UPARROW,32640IDC_SIZE,32641IDC_ICON,32642IDC_SIZENWSE
	,32643IDC_SIZENESW,32644IDC_SIZEWE,32645IDC_SIZENS,32646IDC_SIZEALL
	,32648IDC_NO,32649IDC_HAND,32650IDC_APPSTARTING,32651IDC_HELP
	... (详见附件 “GdOcrTool_Cross 2021-11-25.ahk”)

这里再改一下:增加一行 RestoreCursors()

LButton Up::
LeftButtonUp() {
    Send, {LButton Down}
    StartTime := A_TickCount  ; Start count down after box is drawn.
    SetTimer, CaptureTimeout, 1000
    RestoreCursors()
    Return
}

Esc::
ForceAbortBoxCapture() {
    ToolTip, Aborting box capture.
    SetTimer, TurnOffToolTip, -1000
    ResetCaptureMode()
    RestoreCursors()
    Return
}

改好的GdOcrTool_Cross.ahk:遗憾,系统不允许上传完整的codes!

下载: GdOcrTool_Cross.ahk - Pastebin.com 我提供打包下载:

GdOcrTool_Cross 2021-11-25.zip (3.2 KB)

type or paste code here
2 个赞