
Ask HN: Fastest way to get X/Y position of text/text-based shape in screenshot? - nkkollaw
down vote
favorite
I&#x27;m trying to create a script for Linux that will detect where the text cursor is. This should be done in maximum 1 second. In order to implement this, the best solution seems to be to programmatically add some text via xdotool, take a screenshot via some other utility, try to figure out the position of that text, and then remove the text we&#x27;ve inserted using xdotool again.<p>I tried inserting a random string (like &lt;-- CURSOR HERE). Using Tesseract 4 it takes about 20 seconds to find the position of the string, although it&#x27;s very precise in terms of pixel coordinates. I was not able to use whitelisting (in version 4 of Tesseract) to narrow result to specific letters or digits only, which I assume would speed up processing.<p>I don&#x27;t know what font the user will be using, but every font has dashes and slashes, so I could create some sort of shape (for instance, |&#x2F;\|&#x2F;\|&#x2F;\|&#x2F;\|), and use some library to detect that shape. What would be a good choice?<p>I don&#x27;t care about what&#x27;s on the rest of the screen: it could be more text, images, etc. I only need o know where my random string is (&lt;-- CURSOR HERE, |&#x2F;\|&#x2F;\|&#x2F;\|&#x2F;\|, or can you think of anything else), and get its X&#x2F;Y position in pixels.
======
ainiriand
Do this look like Stackoverflow to you?

~~~
nkkollaw
> Do this look like Stackoverflow to you?

You're right, it don't.

It ain't, even.

