From 32db58c8e41f9cf3ea73dcc3d3d15eb7ff4e39b5 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Sun, 2 Feb 2020 12:28:12 +0300 Subject: [PATCH] #MinorFix in tool ScreenScrapRecognize (x0,x1, y0, y1) Output improvement --- Utils/ToolScreenScrapRecognize/Main.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Utils/ToolScreenScrapRecognize/Main.py b/Utils/ToolScreenScrapRecognize/Main.py index 8be4ceff..bf5871ba 100644 --- a/Utils/ToolScreenScrapRecognize/Main.py +++ b/Utils/ToolScreenScrapRecognize/Main.py @@ -61,7 +61,7 @@ class App(tk.Frame): #Modify rectangle x1, y1 coordinates self.canvas.coords(self.rectid, self.rectx0, self.recty0, self.rectx1, self.recty1) - print('Rectangle x1, y1 = ', self.rectx1, self.recty1) + #print('Rectangle x1, y1 = ', self.rectx1, self.recty1) def stopRect(self, event): #Translate mouse screen x1,y1 coordinates to canvas coordinates @@ -70,7 +70,15 @@ class App(tk.Frame): self.canvas.delete("all") self.parent.attributes('-alpha', 0.0) #Save rect in file png - rect256 = getRectAsImage((int(self.rectx0), int(self.recty0), int(self.rectx1), int(self.recty1))) + + rect256 = getRectAsImage( + ( + int(self.rectx0 if self.rectx0 <= self.rectx1 else self.rectx1), + int(self.recty0 if self.recty0 <= self.recty1 else self.recty1), + int(self.rectx1 if self.rectx0 <= self.rectx1 else self.rectx0), + int(self.recty1 if self.recty0 <= self.recty1 else self.recty0) + ) + ) rect256.save('screencapture_256_256.png', format='png') self.parent.attributes('-alpha', 0.2) #Modify rectangle x1, y1 coordinates @@ -82,9 +90,9 @@ class App(tk.Frame): # Get verbose data including boxes, confidences, line and page numbers print('##Get verbose data including boxes, confidences, line and page numbers##') print(pytesseract.image_to_data(Image.open('screencapture_256_256.png'), lang='rus+eng')) - print('##Get information about orientation and script detection##') # Get information about orientation and script detection - print(pytesseract.image_to_osd(Image.open('screencapture_256_256.png'), lang='rus+eng')) + #print('##Get information about orientation and script detection##') + #print(pytesseract.image_to_osd(Image.open('screencapture_256_256.png'), lang='rus+eng')) if __name__ == "__main__": root = tk.Tk()