Odd OCR behavior after updating to Sequoia 15.1

I've been using this excellent macro just fine for awhile, but noticed today it's not working. When executed, the script displays success, but the System Clipboard ends up with "no printable characters".

After some debugging, I discovered this strange behavior. If I add a Display System Clipboard before the OCR step and a Display System Clipboard the macro suddenly works:

Inconvenient workaround

The trouble with this "solution" is that I end up with two clipboard displays to dismiss, making the macro more confusing and less pleasant to use.

In case you're wondering, it consistently fails unless both displays are active, so this fails with an empty clipboard…

Keyboard Maestro Actions.kmactions (856 B)

Keyboard Maestro Export

…as does this…

Only "after" display enabled

…and this:

Only "before" display enabled

Not sure if this counts as a regression, new bug, or user error, but I swear it was working without the kludge just days ago. Thoughts?

1 Like

Yikes. My initial guess is that somewhere in your system you have a KM action that is triggering on "Clipboard changed." So the first thing you should do is check for that, and disable the clipboard change macro. There's a 50% chance that will fix your problem.

Other things you can try:

  • Try replacing the system clipboard by a named clipboard
  • Try replacing "Languages English" with "Apple Text Recognition". In my opinion, you should never choose "Language English" because it's 6 times slower and has 10 times more errors than "Apple Text Recognition."
  • Try saving the results of the OCR action into a variable rather than a clipboard. Then display the variable instead of the clipboard.
2 Likes

In Sequoia, the Tesseract library Keyboard Maestro uses for most of the OCR (everything except the Apple Text Recognition) crashes frequently with a memory corruption, which almost certainly means there are very subtle bugs in the library that are highly dependent of the system state.

I'd suggest you switch to Apple Text Recognition.

I don't know if I will be able to resolve this issue with Tesseract (debugging this kind of issue would be difficult in my own code - in someone else's code is going to be virtually impossible).

3 Likes

Since Apple Text Recognition is roughly ten times better, it's not a major loss. But I wish you well in fixing it.

2 Likes

Perfect! Would never have thought to look there. Thanks, @Airy! Thanks, @peternlewis!

Yes, in English, I would highly recommend switching to it if it is available.

Unfortunately, Tesseract supports a lot of other languages, and currently there is no support for that within Keyboard Maestro (and I don't know how good the support will be once I do figure out implementing it).

2 Likes

Thank you! I'm new to KBM and was trying this and was very frustrated trying to figure out why it wasn't working. This fixed it!

Hello.
for a language other than English (in my case Turkish);
the following process worked for me and I hope it will work for you:
First I installed Macports.
then I used the command “sudo port install tesseract-tur” to install tesseract and the Turkish language pack (it installs it with the necessary plugins). then the problem was gone. now tesseract works properly with KM.

1 Like