Re: [orca-list] OCR Current Window



Hey out there,

i did some more work on the OCR Window Script. Thanks for your replay and the good explanations :).
What does the script now?
- OCR the whole desktop (i have some problems to find the current window position -> wnck segfaults here, maybe someone know how i can get the coordinates of the active window.) - a "list of" form pops up ( like the cute "list of" feature in the browsers, sorry joanie i stole many of your generic list code, because i was to stupid to just use it for my case)
- you can select a entry
- you can route the mouse over the object
- you can _leftklick/ _rightklick _doubleklick (here i have the problem -> the "list of" window is sometimes overlayed to the object you wanna click to -> here i m searching for a solution. maybe one of you knowes more than i. Just let me know. - the result is stored in you clipboard ( if you wanna copy some strings, just paste in the gedit)

i m also searching for a way to take a screenshot in "the python way" instead of just run gnome-screenshot.

An other (big) problem is that orca does not react to shortcuts if the current window is not accessible ^^. can anybody confirm this problem?

if someone wanna test its on my server:
http://crivatec.de/page/index.php?page=download-area
or just the direct link:
https://crivatec.de/page/uploads/Downloads/Accessible%20Games/orca-customizations.py

its not the cleanest code but it works for me. i will investigate more times later.

# Requiere: python3, tesserwrap >=0.1.6, GTK, tesseract ,PIL , orca >=3.14

Cheers Chrys


Am 28.01.2015 um 15:18 schrieb Mallard:
Hello there,

Oh, bless you!
This function has been performed by a specific add-on in NvDA for quite a while now, and I use it a lot.

It can make quite a bit of difference when ou're working with documents that are images only, like pdf or jpg files, where you have text that hasn't been ocr'd before.

You can also locate buttons, controls and the like, and left- or right click as need be. You can scan the whole window or just an object, which you can pre-select...

Jaws has an internal OCR function too, but I don't know how it works, because I don't have Jaws on my pc. What I know, though, is that it should b based on Omnipage, which is a very bulky programme, though it's more accurate than Tesseract.

Please, keep up this project! This would really enhance the usability and value of Orca for blind users.

Ciao,
Ollie




Il 26/01/2015 23:28, chrys87 ha scritto:
Hi Guys,
i play a little arround with tesserwrap. i dont know if it really make
sense but maybe someone need this.
i wrote a little orca-cust for taking a screen shot of the current
window and pass it through tesseract. just press
orca + m
orca will start reading the content of the window (maybe the image
program or browser with pictures or an other not accessible content) and
set it to the clipboard.
You need tesseract tesserwrap, your tesseract-language-pack and orca >=
3.14

hier is the cust script for those who are interested in:

# Requiere: tesserwrap, tesseract, orca >=3.14
# -*- coding: utf-8 -*-

#Python
import os
from PIL import Image
import locale

#tesseract
from tesserwrap import tesseract

#GTK/GDK
from gi.repository import Gtk, Gdk

# Orca
import orca.orca
import orca.input_event
import orca.settings
import orca.keybindings
import orca.speech
import orca.braille

#Settings-
#this is need by arch for correct braille
orca.settings.tty = 1
#Settings+

#Bind Function to key-
myKeyBindings = orca.keybindings.KeyBindings()

def DefineShortcut(pHandle,pShortcut):
     myKeyBindings.add(orca.keybindings.KeyBinding(
         pShortcut,
         1 << orca.keybindings.MODIFIER_ORCA,
         1 << orca.keybindings.MODIFIER_ORCA,
         pHandle))
     orca.settings.keyBindingsMap["default"] = myKeyBindings
#Bind Function to key+

#OCRPath-
def ocr_path(path):
     img = Image.open(path)
     tr = tesseract("/usr/share")
     new_string = tr.ocr_image(img)
     return new_string
#OCRPath+

#Set to Clipboard
def setTextToClipboard(text):
     ClipboardObj = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
     ClipboardObj.set_text(text, -1)

#Display Message-
#Speak or Braille
def outputMessage(Message):
     if (orca.settings.enableSpeech):
         orca.speech.speak(Message)
     if (orca.settings.enableBraille):
         orca.braille.displayMessage(Message)
#Display Message+

#OCR Current Window-
def ocrWindow(script, inputEvent=None):
os.popen('gnome-screenshot -w -f "/tmp/orca-currwindow.png"').read()
     locale.setlocale(locale.LC_NUMERIC, 'C')
     OCRText = ocr_path("/tmp/orca-currwindow.png")
     setTextToClipboard(OCRText)
     outputMessage(OCRText)
     return True
#OCR Current Window+

# define OcrHandler-
ocrWindowHandler = orca.input_event.InputEventHandler(
     ocrWindow, "OCR Current window") #OCR the current window
# define OcrHandler+


DefineShortcut(ocrWindowHandler,"m"); #Shortcut Orca + m

_______________________________________________
orca-list mailing list
orca-list gnome org
https://mail.gnome.org/mailman/listinfo/orca-list
Visit http://live.gnome.org/Orca for more information on Orca.
The manual is at
http://library.gnome.org/users/gnome-access-guide/nightly/ats-2.html
The FAQ is at http://live.gnome.org/Orca/FrequentlyAskedQuestions
Log bugs and feature requests at http://bugzilla.gnome.org
Find out how to help at http://live.gnome.org/Orca/HowCanIHelp




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]