Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100506

Why my image is in bad quality ?

X-Received by 10.66.138.40 with SMTP id qn8mr38328533pab.7.1450274679252; Wed, 16 Dec 2015 06:04:39 -0800 (PST)
X-Received by 10.50.66.208 with SMTP id h16mr269184igt.9.1450274679222; Wed, 16 Dec 2015 06:04:39 -0800 (PST)
Path csiph.com!au2pb.net!feeder.erje.net!2.us.feeder.erje.net!news.glorb.com!mv3no12785579igc.0!news-out.google.com!f6ni24677igq.0!nntp.google.com!mv3no12785572igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Wed, 16 Dec 2015 06:04:37 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=46.0.40.164; posting-account=zrl2WwoAAAAAF01i_Hw_PRmY2txyq5yy
NNTP-Posting-Host 46.0.40.164
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <b16c8f76-2ca7-4662-aec2-d0fcf3a0ec31@googlegroups.com> (permalink)
Subject Why my image is in bad quality ?
From fsn761304@gmail.com
Injection-Date Wed, 16 Dec 2015 14:04:39 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:100506

Show key headers only | View raw


I'm trying to make OCR-recognition on a screenshot, after screenshot taken it goes to pibxbuffer, which content goes to pytesseract.
But after using pixbuffer image quality is bad (I tried to save it in a directory, instead of pixbuffer, and looked at it).
Below is the problematic snippets of code, further is the whole function.


pixbufObj = Gdk.pixbuf_get_from_window(window, x, y, width, height)
...
image = Image.frombuffer("RGB", (width, height), 
                                 pixbufObj.get_pixels(), 'raw', 'RGB', 0, 1)
        image = image.resize((width*20,height*20), Image.ANTIALIAS)
        ...
        print(pytesseract.image_to_string(image))


Full function:

    def takeScreenshot(self, x, y, width = 150, height = 30):
        self.width=width
        self.height=height
        window = Gdk.get_default_root_window()
        #x, y, width, height = window.get_geometry()

        #print("The size of the root window is {} x {}".format(width, height))

        # get_from_drawable() was deprecated. See:
        # https://developer.gnome.org/gtk3/stable/ch24s02.html#id-1.6.3.4.7
       	pixbufObj = Gdk.pixbuf_get_from_window(window, x, y, width, height)
        height = pixbufObj.get_height()
        width = pixbufObj.get_width()
        image = Image.frombuffer("RGB", (width, height), 
                                 pixbufObj.get_pixels(), 'raw', 'RGB', 0, 1)
        image = image.resize((width*20,height*20), Image.ANTIALIAS)
        #image.save("saved.png")
        print(pytesseract.image_to_string(image))
        
        print("takenScreenshot:",x,y)

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Why my image is in bad quality ? fsn761304@gmail.com - 2015-12-16 06:04 -0800
  Re: Why my image is in bad quality ? Denis McMahon <denismfmcmahon@gmail.com> - 2015-12-16 14:15 +0000
    Re: Why my image is in bad quality ? fsn761304@gmail.com - 2015-12-16 06:21 -0800
      Re: Why my image is in bad quality ? Chris Angelico <rosuav@gmail.com> - 2015-12-17 01:33 +1100
        Re: Why my image is in bad quality ? fsn761304@gmail.com - 2015-12-16 08:33 -0800
          Re: Why my image is in bad quality ? fsn761304@gmail.com - 2015-12-16 08:35 -0800
          Re: Why my image is in bad quality ? Chris Angelico <rosuav@gmail.com> - 2015-12-17 03:41 +1100
            Re: Why my image is in bad quality ? fsn761304@gmail.com - 2015-12-16 09:01 -0800
              Re: Why my image is in bad quality ? fsn761304@gmail.com - 2015-12-16 09:17 -0800
                Re: Why my image is in bad quality ? BartC <bc@freeuk.com> - 2015-12-16 21:36 +0000
                Re: Why my image is in bad quality ? fsn761304@gmail.com - 2015-12-16 13:53 -0800
                Re: Why my image is in bad quality ? BartC <bc@freeuk.com> - 2015-12-16 23:20 +0000
  Re: Why my image is in bad quality ? Nobody <nobody@nowhere.invalid> - 2015-12-17 01:27 +0000
    Re: Why my image is in bad quality ? fsn761304@gmail.com - 2015-12-17 03:31 -0800

csiph-web