Hocr - הפיכת תמונה עם אותיות עבריות לקובץ טקסט/המרה לטקסט: הבדלים בין גרסאות בדף

תוכן שנמחק תוכן שנוסף
Mintz l (שיחה | תרומות)
שורה 58:
תסריט דוגמה המשתמש ב hocr לביצוע זיהוי האותיות וב gtk לצורך יבוא קובץ התמונה: [http://hocr.berlios.de/code/hocr_python.py hocr_python.py]
 
<source lang="python">
<div style="direction: ltr;">
import sys
import gtk
# import the ocr unit
from hocr import *
# load the picture
gtk_pix = gtk.gdk.pixbuf_new_from_file (sys.argv[1])
# Create an hocr pixbuf
pix = ho_pixbuf_new (gtk_pix.get_n_channels(),
gtk_pix.get_width(), gtk_pix.get_height (),
gtk_pix.get_rowstride ())
ho_pixbuf_set_data (pix, gtk_pix.get_pixels())
# create a new hocr object
hocr_obj = Hocr(pix)
# do ocr
hocr_obj.do_ocr()
# print text
print hocr_obj.get_text()
 
# import the ocr unit
</div>
from hocr import *
 
# load the picture
gtk_pix = gtk.gdk.pixbuf_new_from_file (sys.argv[1])
 
# Create an hocr pixbuf
pix = ho_pixbuf_new (gtk_pix.get_n_channels(),
gtk_pix.get_width(), gtk_pix.get_height (),
gtk_pix.get_rowstride ())
 
ho_pixbuf_set_data (pix, gtk_pix.get_pixels())
 
# create a new hocr object
hocr_obj = Hocr(pix)
 
# do ocr
hocr_obj.do_ocr()
 
# print text
print hocr_obj.get_text()
</source>
 
דוגמאות נוספות לשימוש בתסריטים ניתן לראות באתר התכנה: