Library for applying OCR to where the user is looking.
Project description
gaze-ocr
The gaze-ocr package makes easy to apply OCR to wherever the user is looking.
This library is designed for voice control. The following instructions are for
use with Dragonfly. For Talon, see
https://github.com/wolfmanstout/talon-gaze-ocr. See handsfreecoding.org for more
information about this package.
Installation
- Follow instructions for installing screen-ocr.
- Download the latest Tobii.Interaction package from NuGet (these instructions have been tested on 0.7.3).
- Rename the file extension to .zip and expand the contents.
- Copy these 3 DLLs to a directory of your choice: build/AnyCPU/Tobii.EyeX.Client.dll, lib/net45/Tobii.Interaction.Model.dll, lib/net45/Tobii.Interaction.Net.dll.
- Ensure that the files are not blocked (right-click Properties, and if there is a "Security" section at the bottom, check the "Unblock" box.)
pip install gaze-ocr[dragonfly]
Usage
Provide the path to the DLL directory when constructing an EyeTracker instance.
Sample Dragonfly grammar:
import gaze_ocr
import gaze_ocr.dragonfly
import gaze_ocr.eye_tracking
import screen_ocr
from dragonfly import (
Dictation,
Grammar,
Key,
MappingRule,
Mouse,
Text
)
# See installation instructions:
# https://github.com/wolfmanstout/gaze-ocr
DLL_DIRECTORY = "c:/Users/james/Downloads/tobii.interaction.0.7.3/"
# Initialize eye tracking and OCR.
tracker = gaze_ocr.eye_tracking.EyeTracker.get_connected_instance(DLL_DIRECTORY,
mouse=gaze_ocr.dragonfly.Mouse(),
keyboard=gaze_ocr.dragonfly.Keyboard(),
windows=gaze_ocr.dragonfly.Windows())
ocr_reader = screen_ocr.Reader.create_fast_reader()
gaze_ocr_controller = gaze_ocr.Controller(ocr_reader,
tracker,
mouse=gaze_ocr.dragonfly.Mouse(),
keyboard=gaze_ocr.dragonfly.Keyboard())
class CommandRule(MappingRule):
mapping = {
# Click on text.
"<text> click": gaze_ocr.dragonfly.MoveCursorToWordAction(gaze_ocr_controller, "%(text)s") + Mouse("left"),
# Move the cursor for text editing.
"go before <text>": gaze_ocr.dragonfly.MoveTextCursorAction(gaze_ocr_controller, "%(text)s", "before"),
"go after <text>": gaze_ocr.dragonfly.MoveTextCursorAction(gaze_ocr_controller, "%(text)s", "after"),
# Select text starting from the current position.
"words before <text>": Key("shift:down") + gaze_ocr.dragonfly.MoveTextCursorAction(gaze_ocr_controller, "%(text)s", "before") + Key("shift:up"),
"words after <text>": Key("shift:down") + gaze_ocr.dragonfly.MoveTextCursorAction(gaze_ocr_controller, "%(text)s", "after") + Key("shift:up"),
# Select a phrase or range of text.
"words <text> [through <text2>]": gaze_ocr.dragonfly.SelectTextAction(gaze_ocr_controller, "%(text)s", "%(text2)s"),
# Select and replace text.
"replace <text> with <replacement>": gaze_ocr.dragonfly.SelectTextAction(gaze_ocr_controller, "%(text)s") + Text("%(replacement)s"),
}
extras = [
Dictation("text"),
Dictation("text2"),
Dictation("replacement"),
]
def _process_begin(self):
# Start OCR now so that results are ready when the command completes.
gaze_ocr_controller.start_reading_nearby()
grammar = Grammar("ocr_test")
grammar.add_rule(CommandRule())
grammar.load()
# Unload function which will be called by natlink at unload time.
def unload():
global grammar
if grammar: grammar.unload()
grammar = None
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gaze_ocr-0.5.0.tar.gz.
File metadata
- Download URL: gaze_ocr-0.5.0.tar.gz
- Upload date:
- Size: 115.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b75dddca09f520021f48a9d141cd1c854556edb84d62cb339938794ab41e007
|
|
| MD5 |
f5b697e625cf4902d9c7e26f9f59c629
|
|
| BLAKE2b-256 |
a5b6de018a31b71a91e67f75bdb5bf24bce3969a232a904b1cca000ae020478a
|
Provenance
The following attestation bundles were made for gaze_ocr-0.5.0.tar.gz:
Publisher:
publish.yml on wolfmanstout/gaze-ocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gaze_ocr-0.5.0.tar.gz -
Subject digest:
1b75dddca09f520021f48a9d141cd1c854556edb84d62cb339938794ab41e007 - Sigstore transparency entry: 451539965
- Sigstore integration time:
-
Permalink:
wolfmanstout/gaze-ocr@fd5985857e5bcddb7fa0ab2ec1a2179b904a66fe -
Branch / Tag:
refs/tags/0.5.0 - Owner: https://github.com/wolfmanstout
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fd5985857e5bcddb7fa0ab2ec1a2179b904a66fe -
Trigger Event:
release
-
Statement type:
File details
Details for the file gaze_ocr-0.5.0-py3-none-any.whl.
File metadata
- Download URL: gaze_ocr-0.5.0-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a252bd6acae6787931b365465b7e681135fc086ffb9bf960d1d7ba3a6508b388
|
|
| MD5 |
0d4f47bb96148eac2cb43aecdb7b4e81
|
|
| BLAKE2b-256 |
bf69cb90444cccb408d2daeae6cbeae627b54f301717b17307ea77e9ee8a10e8
|
Provenance
The following attestation bundles were made for gaze_ocr-0.5.0-py3-none-any.whl:
Publisher:
publish.yml on wolfmanstout/gaze-ocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gaze_ocr-0.5.0-py3-none-any.whl -
Subject digest:
a252bd6acae6787931b365465b7e681135fc086ffb9bf960d1d7ba3a6508b388 - Sigstore transparency entry: 451539986
- Sigstore integration time:
-
Permalink:
wolfmanstout/gaze-ocr@fd5985857e5bcddb7fa0ab2ec1a2179b904a66fe -
Branch / Tag:
refs/tags/0.5.0 - Owner: https://github.com/wolfmanstout
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fd5985857e5bcddb7fa0ab2ec1a2179b904a66fe -
Trigger Event:
release
-
Statement type: