def load_image(data=None): global cvImg global pixbuf path = browse_for("image") SciOCR.loadImg(path, cvImg) pixbuf = gtk.gdk.pixbuf_new_from_file(path) create_window()
def recognise(data=None): global cvImg global cvProcessed global lstm global vec global ctext SciOCR.preprocessing(cvImg, cvProcessed) SciOCR.shredder(vec, cvProcessed) ctext = SciOCR.ocr(vec, cvProcessed, lstm) print "Done"
def on_left_click(event): gtk.gdk.pointer_ungrab(0L) global cvImg global pixbuf suc = SciOCR.getScreen(cvImg) if( suc == 1 ): exit(1) step = cvImg.cols*3 pixbuf = gtk.gdk.pixbuf_new_from_data(cvImg.data(), gtk.gdk.COLORSPACE_RGB, False, 8, cvImg.cols, cvImg.rows, step) recognise('activate') create_window()
def save(self, window): global cvImg global cvProcessed global ctext global textBuf global vec if (ctext != ""): start = textBuf.get_start_iter() end = textBuf.get_end_iter() ctext = textBuf.get_text(start, end, True) SciOCR.SaveAll(cvImg, cvProcessed, vec, ctext) #~ cvProcessed.save() destroy_window(self, window)
def on_left_click(event): gtk.gdk.pointer_ungrab(0L) global cvImg global pixbuf suc = SciOCR.getScreen(cvImg) if (suc == 1): exit(1) step = cvImg.cols * 3 pixbuf = gtk.gdk.pixbuf_new_from_data(cvImg.data(), gtk.gdk.COLORSPACE_RGB, False, 8, cvImg.cols, cvImg.rows, step) recognise('activate') create_window()
#!/usr/bin/env python2 from lib import SciOCR import pygtk pygtk.require('2.0') import gtk protoNet = "/home/fedor/Project/SciOCR/data/net/ruphy-28000.model.proto" lstm = SciOCR.Clstm() lstm.load(protoNet) cvImg = SciOCR.Mat() cvProcessed = SciOCR.Mat() pixbuf = gtk.gdk.pixbuf_new_from_file("./data/dummy.bmp") vec = SciOCR.vect_of_rect() textBuf = gtk.TextBuffer() ctext = "" def browse_for(type): """This function is used to browse for an image. The path to the image will be returned if the user selects one, however a blank string will be returned if they cancel or do not select one.""" if (type == "image"): title = "Select Image" elif (type == "clstm_net"): title = "Select lstm net file" else: title = "Something wrong!" file_open = gtk.FileChooserDialog(
#!/usr/bin/env python2 from lib import SciOCR import pygtk pygtk.require('2.0') import gtk protoNet = "/home/fedor/Project/SciOCR/data/net/ruphy-28000.model.proto" lstm = SciOCR.Clstm() lstm.load(protoNet) cvImg = SciOCR.Mat() cvProcessed = SciOCR.Mat() pixbuf = gtk.gdk.pixbuf_new_from_file("./data/dummy.bmp") vec = SciOCR.vect_of_rect() textBuf = gtk.TextBuffer() ctext = "" def browse_for(type): """This function is used to browse for an image. The path to the image will be returned if the user selects one, however a blank string will be returned if they cancel or do not select one.""" if( type == "image" ): title="Select Image" elif( type == "clstm_net" ): title="Select lstm net file" else: title="Something wrong!" file_open = gtk.FileChooserDialog(title , action=gtk.FILE_CHOOSER_ACTION_OPEN