[Pycodeocr-main] SF.net SVN: pycodeocr:[49] trunk
Status: Beta
Brought to you by:
drtrigon
|
From: <drt...@us...> - 2011-04-27 19:02:00
|
Revision: 49
http://pycodeocr.svn.sourceforge.net/pycodeocr/?rev=49&view=rev
Author: drtrigon
Date: 2011-04-27 19:01:54 +0000 (Wed, 27 Apr 2011)
Log Message:
-----------
some followup to r47, main-window improved, checksum class and char_correction updated
Modified Paths:
--------------
trunk/CHANGES
trunk/PyCodeOCR.glade
trunk/PyCodeOCR.py
trunk/checksum.py
trunk/requirements.py
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2011-04-27 15:51:57 UTC (rev 48)
+++ trunk/CHANGES 2011-04-27 19:01:54 UTC (rev 49)
@@ -25,6 +25,7 @@
# CHANGES:
#
# * (Version 1.1):
+# - [ r18 - HEAD ]
# - Added support for barcodes with gocr (somehow preliminary). Can find and
# recognize the code automatic, therefore the whole page is scanned. [expermental
# or beta]
Modified: trunk/PyCodeOCR.glade
===================================================================
--- trunk/PyCodeOCR.glade 2011-04-27 15:51:57 UTC (rev 48)
+++ trunk/PyCodeOCR.glade 2011-04-27 19:01:54 UTC (rev 49)
@@ -340,7 +340,6 @@
<property name="urgency_hint">True</property>
<property name="deletable">False</property>
<property name="transient_for">window1</property>
- <signal name="destroy" handler="on_window2_destroy"/>
<child>
<widget class="GtkFixed" id="fixed1">
<property name="visible">True</property>
Modified: trunk/PyCodeOCR.py
===================================================================
--- trunk/PyCodeOCR.py 2011-04-27 15:51:57 UTC (rev 48)
+++ trunk/PyCodeOCR.py 2011-04-27 19:01:54 UTC (rev 49)
@@ -9,6 +9,9 @@
#
# $Id$
#
+# @todo This module/script has become large (more than 1000 lines)
+# and should be splitted into seperate files.
+#
# For further information please consult the @ref mainpage also.
#
# @mainpage PyCodeOCR
@@ -278,11 +281,12 @@
self.on_eventbox2_button_press_event()
def on_pointer_motion(self, source=None, event=None):
- (x,y,state) = self.window1.window.get_pointer()
- (wxim, wyim ) = self.image1.get_size_request()
- if x > 16+(wxim-self.new_width)/2 and x < 16+(wxim+self.new_width)/2 and y > 75+(wyim-self.new_height)/2 and y < 75+(wyim+self.new_height)/2:
- if not self.window3.get_visible():
- self.on_eventbox2_button_press_event()
+ pass
+# (x,y,state) = self.window1.window.get_pointer()
+# (wxim, wyim ) = self.image1.get_size_request()
+# if x > 16+(wxim-self.new_width)/2 and x < 16+(wxim+self.new_width)/2 and y > 75+(wyim-self.new_height)/2 and y < 75+(wyim+self.new_height)/2:
+# if not self.window3.get_visible():
+# self.on_eventbox2_button_press_event()
def on_eventbox2_button_press_event(self, source=None, event=None):
if self.window3.get_visible():
@@ -422,16 +426,6 @@
pass
# exit
gtk.main_quit()
-
- ## press x-button on device select window
- def on_window2_destroy(self, source=None):
- # when windows is closed by pressing the x-button
- # choose first device
- devnr = 0
- # init scanner
- self.run_sane.init_scanner(self.progress, self.window2, self.treeview1, devnr)
- # set sensitivity
- self.init_sensitivity()
## file selected
def on_filechooserbutton1_file_set(self, source=None):
@@ -450,8 +444,10 @@
def toggle_placement_sensitive(self, value):
if self.radiobutton2.get_active():
self.frame1.set_sensitive(value)
+ self.filechooserbutton1.set_sensitive(False)
else:
self.frame1.set_sensitive(False)
+ self.filechooserbutton1.set_sensitive(True)
# helpers
#
@@ -494,7 +490,7 @@
#dmtxread recognition
opt = { 'tmp_file': "02.jpg", # some issues with recogition
'recog_class': RunExternal, # .
- 'recog_cmd': "%s %s02.jpg"%(paths["dmtxread"],self.temp), # of different file formats
+ 'recog_cmd': "%s -v -D %s02.jpg"%(paths["dmtxread"],self.temp), # of different file formats
'recog_error_msg': [ "error" ], # .
#opt = { 'tmp_file': "02.bmp", # and drawing/marking the
@@ -633,16 +629,13 @@
reference = tmp[0]
account = tmp[1]
# initialize modulo10 checksum
- m10 = modulo10()
+ m10 = modulo10(amount, account, reference)
# check amount, account number and reference number
- checksum_b = (int(amount[-1]) == m10.run(amount[:-1]) )
- checksum_k = (int(account[-1]) == m10.run(account[:-1]) )
- checksum_r = (int(reference[-1]) == m10.run(reference[:-1]) )
- print "Amount: "+str(int(amount[2:-1])/100.),checksum_b
- print "Account number: "+account,checksum_k
- print "Reference number: "+reference,checksum_r
+ print "Amount:", m10.amount, m10.checksum_b
+ print "Account number:", m10.account, m10.checksum_k
+ print "Reference number:", m10.reference, m10.checksum_r
- checksum = checksum_b and checksum_k and checksum_r
+ checksum = m10.checksum
# if len(data) == 42:
# # extract details
@@ -688,11 +681,10 @@
# Data final output
# (6/?)
self.progress(6./max_steps, "Final data output...")
+ self.entry1.set_text(data)
if check:
os.remove(self.temp+opt['tmp_file']) # clean-up
- self.entry1.set_text(data)
-
# get the clipboard
clipboard = gtk.clipboard_get()
# set the clipboard text data
@@ -795,7 +787,7 @@
print data
corrections = [
# Zero
- ("O", "0"), ("D", "0"), ("U", "0"), ("Q", "0"), ("\(\)", "0"), ("G", "0"),
+ ("O", "0"), ("D", "0"), ("U", "0"), ("Q", "0"), ("\(\)", "0"), ("G", "0"), ("o", "0"),
# Two
("Z", "2"),
# Three
@@ -833,6 +825,7 @@
("\x98", ""),
("\x5f", ""),
("\x60", ""),
+ ("'", ""),
#('\xbb', 187)('\x99', 153)('\x98', 152)
("\+", "+ "),
("\x92", "1"), # post correction
Modified: trunk/checksum.py
===================================================================
--- trunk/checksum.py 2011-04-27 15:51:57 UTC (rev 48)
+++ trunk/checksum.py 2011-04-27 19:01:54 UTC (rev 49)
@@ -19,13 +19,29 @@
# much more details http://www.sic.ch/de/dl_tkicch_dta.pdf ( page 51 )
# @see http://www.bundesbank.de/download/zahlungsverkehr/zv_pz201012.pdf
# @see http://www.bundesbank.de/zahlungsverkehr/zahlungsverkehr_pruefziffernberechnung.php
- def __init__(self):
+ def __init__(self, amount, account, reference):
self.tabelle = [0,9,4,6,8,2,7,1,3,5]
+
+ self.account = account
+ self.reference = reference
- def run(self,nr):
+ self.checksum_b = self._checksum(amount)
+ self.checksum_k = self._checksum(account)
+ self.checksum_r = self._checksum(reference)
+ self.checksum = self.checksum_b and self.checksum_k and self.checksum_r
+
+ try:
+ self.amount = str(int(amount[2:-1])/100.)
+ except ValueError:
+ self.amount = amount + " (error)"
+
+ def _run(self, nr):
self.uebertrag = 0
# iterate over each character
for i in range(len(nr)):
self.uebertrag = self.tabelle[(self.uebertrag + int(nr[i]) )%10]
return (10-self.uebertrag)%10
+
+ def _checksum(self, value):
+ return (int(value[-1]) == self._run(value[:-1]) )
Modified: trunk/requirements.py
===================================================================
--- trunk/requirements.py 2011-04-27 15:51:57 UTC (rev 48)
+++ trunk/requirements.py 2011-04-27 19:01:54 UTC (rev 49)
@@ -218,6 +218,7 @@
#require_python_module('pydmtx')
require_executable("dmtxread")
except MissingRequirement:
+ #r = installbundle.install({'linux-fedora': ['python-libdmtx']})
r = installbundle.install({'linux-fedora': ['libdmtx-utils'],
'linux-ubuntu': ['libdmtx-utils']})
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|