Re: [orca-list] OCR Current Window



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]