Skip to content

Commit

Permalink
0.6.0.3
Browse files Browse the repository at this point in the history
improved learning wizard, small fixes
  • Loading branch information
seeebek committed May 4, 2015
1 parent 27ef626 commit d1bc7f9
Show file tree
Hide file tree
Showing 12 changed files with 261 additions and 675 deletions.
8 changes: 5 additions & 3 deletions EliteOCR.py
Expand Up @@ -3,6 +3,7 @@
import logging
import traceback
import sys
import re
import getopt
#import time
import json
Expand Down Expand Up @@ -55,15 +56,16 @@ def _translate(context, text, disambig):
def _translate(context, text, disambig):
return QApplication.translate(context, text, disambig)

appversion = "0.6.0.2"
appversion = "0.6.0.3"
gui = False
logging.basicConfig(format='%(asctime)s %(levelname)s:\n%(message)s',filename='errorlog.txt',level=logging.WARNING)

def exception_handler(ex_cls, ex, tb):
fulltb = ''.join(traceback.format_tb(tb))
fulltb = fulltb.replace("<string>", "EliteOCR")
fulltb = fulltb.replace("C:"+ os.sep +"Users"+ os.sep +"SEBAST~1"+ os.sep +"Desktop"+ os.sep +"RFACTO~2"+ os.sep +"build"+ os.sep +"EliteOCR"+ os.sep +"out00-PYZ.pyz"+ os.sep +"", "")
fulltb = fulltb.replace("C:"+ os.sep +"Users"+ os.sep +"SEBAST~1"+ os.sep +"Desktop"+ os.sep +"RFACTO~2"+ os.sep +"build"+ os.sep +"EliteOCRcmd"+ os.sep +"out00-PYZ.pyz"+ os.sep +"", "")
fulltb = re.sub(r"C:.+\.pyz", "", fulltb)
#fulltb = fulltb.replace("C:"+ os.sep +"Users"+ os.sep +"SEBAST~1"+ os.sep +"Desktop"+ os.sep +"RFACTO~2"+ os.sep +"build"+ os.sep +"EliteOCR"+ os.sep +"out00-PYZ.pyz"+ os.sep +"", "")
#fulltb = fulltb.replace("C:"+ os.sep +"Users"+ os.sep +"SEBAST~1"+ os.sep +"Desktop"+ os.sep +"RFACTO~2"+ os.sep +"build"+ os.sep +"EliteOCRcmd"+ os.sep +"out00-PYZ.pyz"+ os.sep +"", "")
logging.critical(fulltb+'\n{0}: {1}\n'.format(ex_cls, ex))
print "An error was encountered. Please read errorlog.txt"
#print gui
Expand Down
12 changes: 7 additions & 5 deletions EliteOCRcmd.py
Expand Up @@ -3,6 +3,7 @@
import logging
import traceback
import sys
import re
import getopt
#import time
import json
Expand Down Expand Up @@ -55,18 +56,19 @@ def _translate(context, text, disambig):
def _translate(context, text, disambig):
return QApplication.translate(context, text, disambig)

appversion = "0.6.0.2"
appversion = "0.6.0.3"
gui = False
logging.basicConfig(format='%(asctime)s %(levelname)s:\n%(message)s',filename='errorlog.txt',level=logging.WARNING)

def exception_handler(ex_cls, ex, tb):
fulltb = ''.join(traceback.format_tb(tb))
fulltb = fulltb.replace("<string>", "EliteOCR")
fulltb = fulltb.replace("C:"+ os.sep +"Users"+ os.sep +"SEBAST~1"+ os.sep +"Desktop"+ os.sep +"RFACTO~2"+ os.sep +"build"+ os.sep +"EliteOCR"+ os.sep +"out00-PYZ.pyz"+ os.sep +"", "")
fulltb = fulltb.replace("C:"+ os.sep +"Users"+ os.sep +"SEBAST~1"+ os.sep +"Desktop"+ os.sep +"RFACTO~2"+ os.sep +"build"+ os.sep +"EliteOCRcmd"+ os.sep +"out00-PYZ.pyz"+ os.sep +"", "")
fulltb = re.sub(r"C:.+\.pyz", "", fulltb)
#fulltb = fulltb.replace("C:"+ os.sep +"Users"+ os.sep +"SEBAST~1"+ os.sep +"Desktop"+ os.sep +"RFACTO~2"+ os.sep +"build"+ os.sep +"EliteOCR"+ os.sep +"out00-PYZ.pyz"+ os.sep +"", "")
#fulltb = fulltb.replace("C:"+ os.sep +"Users"+ os.sep +"SEBAST~1"+ os.sep +"Desktop"+ os.sep +"RFACTO~2"+ os.sep +"build"+ os.sep +"EliteOCRcmd"+ os.sep +"out00-PYZ.pyz"+ os.sep +"", "")
logging.critical(fulltb+'\n{0}: {1}\n'.format(ex_cls, ex))
print "An error was encountered. Please read errorlog.txt"
print gui
#print gui
if gui:
QMessageBox.critical(None,"Error", "An error was encountered. Please read errorlog.txt")

Expand Down Expand Up @@ -414,7 +416,7 @@ def addAllScreenshots(self):
dir = unicode(self.settings['screenshot_dir'])
#gen = (join(dir, file).decode('windows-1252') for file in listdir(dir) if isfile(join(dir, file)))
gen = [join(dir, file) for file in listdir(dir) if file.endswith('.bmp') and file[:7]!="HighRes"]
print gen
#print gen
files = []
for file in gen:
files.append(file)
Expand Down
35 changes: 20 additions & 15 deletions customqlistwidgetitem.py
Expand Up @@ -10,8 +10,8 @@
from time import gmtime, localtime, strftime
from tzlocal import get_localzone
from datetime import datetime, timedelta
from PyQt4.QtGui import QListWidgetItem, QPixmap
from PyQt4.QtCore import QRect
from PyQt4.QtGui import QListWidgetItem, QPixmap, QImage, qRgba, qGray, qAlpha
from PyQt4.QtCore import Qt, QRect
from qimage2ndarray import array2qimage
from imageprocessing import *
#from ocrmethods import OCRAreasFinder
Expand Down Expand Up @@ -66,30 +66,34 @@ def addTestImage(self, color_image):
self.ocr_areas = OCRAreasFinder(color_image, self.settings["contrast"])
self.market_width = self.ocr_areas.market_width
self.valid_market = self.ocr_areas.valid
img = QPixmap(self.hiddentext)
width = img.width()
height = img.height()
aspect_ratio = float(width)/height
if aspect_ratio > 1.78:
new_w = int(1.77778*height)
rect = QRect((width-new_w)/2, 0, new_w, height)
img = img.copy(rect)
if self.settings['gray_preview']:
img = cv2.imread(unicode(self.hiddentext).encode(sys.getfilesystemencoding()), 0)
img = array2qimage(img)
pix = QPixmap.fromImage(img)
else:
pix = QPixmap(self.hiddentext)
width = pix.width()
height = pix.height()
if height > 0:
aspect_ratio = float(width)/height
if aspect_ratio > 1.78:
new_w = int(1.77778*height)
rect = QRect((width-new_w)/2, 0, new_w, height)
pix = pix.copy(rect)

if self.valid_market:
points = self.ocr_areas.market_table
self.market_offset = (points[0][0], points[0][1])
station = self.ocr_areas.station_name
self.station_offset = (station[0][0], station[0][1])
rect = QRect(0, 0, points[1][0] + 20, points[1][1] + 20)
cut = img.copy(rect)
cut = pix.copy(rect)
return cut
else:
self.market_offset = (0, 0)
self.station_offset = (0, 0)



return img
return pix

def addPreviewImage(self, color_image, parent = None):
image = color_image
Expand Down Expand Up @@ -205,4 +209,5 @@ def parseLogFile(self, path, loglist, y, m, d, hour, minute):
else:
if re.match(matchscreen, line):
screenshotfound = True
return ""
return ""

4 changes: 2 additions & 2 deletions eliteOCRGUI.py
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'eliteOCRGUI.ui'
#
# Created: Mon Apr 27 13:47:22 2015
# Created: Mon May 04 19:58:58 2015
# by: PyQt4 UI code generator 4.11.2
#
# WARNING! All changes made in this file will be lost!
Expand Down Expand Up @@ -553,7 +553,7 @@ def setupUi(self, MainWindow):

def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "EliteOCR", None))
self.label_2.setText(_translate("MainWindow", "<html><head/><body><p>If you have any problems please read &quot;Help&quot;. Please send any bug reports, issues or suggestions to eliteocr@gmail.com or post them in the <a href=\"https://forums.frontier.co.uk/showthread.php?t=68771\"><span style=\" text-decoration: underline; color:#0000ff;\">forum.</span></a></p></body></html>", None))
self.label_2.setText(_translate("MainWindow", "<html><head/><body><p>If you have any problems please <span style=\" font-weight:600; text-decoration: underline;\">read &quot;Help&quot;</span>. Please send any bug reports, issues or suggestions to eliteocr@gmail.com or post them in the <a href=\"https://forums.frontier.co.uk/showthread.php?t=68771\"><span style=\" text-decoration: underline; color:#0000ff;\">forum.</span></a></p></body></html>", None))
self.add_button.setText(_translate("MainWindow", "...", None))
self.add_button.setShortcut(_translate("MainWindow", "Alt+Q", None))
self.remove_button.setText(_translate("MainWindow", "...", None))
Expand Down
2 changes: 1 addition & 1 deletion eliteOCRGUI.ui
Expand Up @@ -51,7 +51,7 @@
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If you have any problems please read &amp;quot;Help&amp;quot;. Please send any bug reports, issues or suggestions to eliteocr@gmail.com or post them in the &lt;a href=&quot;https://forums.frontier.co.uk/showthread.php?t=68771&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;forum.&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If you have any problems please &lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;read &amp;quot;Help&amp;quot;&lt;/span&gt;. Please send any bug reports, issues or suggestions to eliteocr@gmail.com or post them in the &lt;a href=&quot;https://forums.frontier.co.uk/showthread.php?t=68771&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;forum.&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
Expand Down

0 comments on commit d1bc7f9

Please sign in to comment.