def _locate_all_barcodes_in_image(self): """ Perform a deep scan to find all the datamatrix barcodes in the image (but don't read them). """ if self._is_single_image: barcodes = DataMatrix.locate_all_barcodes_in_image_deep(self._frame_img, self.barcode_size) else: barcodes = DataMatrix.locate_all_barcodes_in_image(self._frame_img, self.barcode_size) if len(barcodes) == 0: raise NoBarcodesError("No Barcodes Detected In Image") return barcodes
def _locate_all_barcodes_in_image(self): if self._is_single_image: # barcodes = DataMatrix.locate_all_barcodes_in_image_deep(self._frame_img, self.barcode_size) barcodes = DataMatrix.locate_all_barcodes_in_image(self._frame_img, self.barcode_size) else: barcodes = DataMatrix.locate_all_barcodes_in_image(self._frame_img, self.barcode_size) if len(barcodes) == 0: raise NoBarcodesError("No Barcodes Detected In Image") return barcodes
def _locate_all_barcodes_in_image(self): if self._is_single_image: # barcodes = DataMatrix.locate_all_barcodes_in_image_deep(self._frame_img, self.barcode_sizes) barcodes = DataMatrix.locate_all_barcodes_in_image(self._frame_img, self.barcode_sizes) else: barcodes = DataMatrix.locate_all_barcodes_in_image(self._frame_img, self.barcode_sizes) if len(barcodes) == 0: raise NoBarcodesDetectedError() return barcodes
def _locate_all_barcodes_in_image(self): """ Perform a deep scan to find all the datamatrix barcodes in the image (but don't read them). """ if self._is_single_image: barcodes = DataMatrix.locate_all_barcodes_in_image_deep( self._frame_img, self.barcode_sizes) else: barcodes = DataMatrix.locate_all_barcodes_in_image( self._frame_img, self.barcode_sizes) # TODO: log the error if len(barcodes) == 0: raise NoBarcodesDetectedError() return barcodes
def _locate_all_barcodes_in_image(self): barcodes = DataMatrix.locate_all_barcodes_in_image(self._frame_img, self.barcode_sizes) # TODO: log this if len(barcodes) == 0: raise NoBarcodesDetectedError() return barcodes
def deep_scan(self, slot): if not self._is_slot_worth_scanning(slot): return [] img = self._slot_image(slot) fps = list(Locator().locate_deep(img, self.radius_avg)) barcodes = [DataMatrix(fp, img) for fp in fps] self._DEBUG_MULTI_FP_IMAGE(img, fps, slot.number()) return barcodes
def square_scan(self, slot): if not self._is_slot_worth_scanning(slot): return None img = self._slot_image(slot) fp = Locator().locate_square(img, self.side_avg) barcode = None if fp is not None: self._DEBUG_SQUARE_LOCATOR(img, fp, slot.number()) barcode = DataMatrix(fp, img) return barcode
from dls_barcode.datamatrix import DataMatrix from dls_util import Image, Color dm_img_file = '../tests/test-resources/test/dm6.png' dm_img = Image.from_file(dm_img_file) mono_img = dm_img.to_grayscale() barcodes = DataMatrix.locate_all_barcodes_in_image(mono_img, matrix_sizes=[18]) for barcode in barcodes: barcode.draw(dm_img, Color.Green()) barcode.perform_read() print(barcode.data()) print(barcode._error_message) dm_img.popup() from dls_barcode.datamatrix.read import ReedSolomonDecoder # msg = 16, 16 ecc chars = [69, 71, 145, 49, 70, 134, 173, 69, 71, 145, 49, 70, 134, 173, 129] decoder = ReedSolomonDecoder() out = decoder.encode(chars, 17) print([int(b) for b in out], len(out))