11import logging
2+ import string
3+ from string import ascii_lowercase
4+
5+ from pylibdmtx .pylibdmtx import decode
6+
27from dls_util .image .image import Image
8+
39from .locate import Locator
4- from pylibdmtx .pylibdmtx import decode
5- import string
610
711# We predict the location of the center of each square (pixel/bit) in the datamatrix based on the
812# size and location of the finder pattern, but this can sometimes be slightly off. If the initial
@@ -25,9 +29,7 @@ class DataMatrix:
2529 DEFAULT_SIZE = 14
2630 DEFAULT_SIDE_SIZES = [12 , 14 ]
2731 # allow only capitol letters, digits and dash in the decoded string
28- ALLOWED_CHARS = set (string .ascii_uppercase + string .digits + '-' )
29- # allow up to 10 chars in the decoded string
30- ALLOWED_NUMBER_OF_CHARS = 11
32+ ALLOWED_CHARS = set (string .ascii_uppercase + string .ascii_lowercase + string .digits + '-' + '_' )
3133
3234 def __init__ (self , finder_pattern ):
3335 """ Initialize the DataMatrix object with its finder pattern location in an image. To actually
@@ -114,7 +116,7 @@ def _read(self, gray_image):
114116 if len (result ) > 0 :
115117 d = result [0 ].data
116118 decoded = d .decode ('UTF-8' )
117- if self ._contains_allowed_chars_only (decoded ) and len ( decoded ) < self . ALLOWED_NUMBER_OF_CHARS :
119+ if self ._contains_allowed_chars_only (decoded ):
118120 new_line_removed = decoded .replace ("\n " ,"" )
119121 self ._data = new_line_removed
120122 self ._read_ok = True
0 commit comments