CoolFace
Datasetpublic

shortery/dm-codes

DM codes dataset The dataset contains photos of Data Matrix (DM) codes and their annotations. The photos were taken on an iPhone and annotated manually by a human. The annotations contain text, which is encoded in the DM code and the pixel coordinates of the DM code vertices. The vertices are: tl = top left, tr = top right, br = bottom right, bl = bottom left. Attribute is_clean specifies whether the DM code on the image is expected to be easily readable. For every DM code… See the full description on the dataset page: https://huggingface.co/datasets/shortery/dm-codes.

sourceHugging Facemitupdated 2y agoView on Hugging Face
2likes58downloads
Dataset Card

DM codes dataset

The dataset contains photos of Data Matrix (DM) codes and their annotations. The photos were taken on an iPhone and annotated manually by a human. The annotations contain text, which is encoded in the DM code and the pixel coordinates of the DM code vertices. The vertices are: tl = top left, tr = top right, br = bottom right, bl = bottom left. Attribute is_clean specifies whether the DM code on the image is expected to be easily readable. For every DM code, there is exactly one image with is_clean=true and several images with is_clean=false.

If you want to crop the DM codes from the images, use the following code:

python
import numpy as np
import datasets
from PIL import Image
from skimage import transform

def crop_dm_code(example: dict, square_side: int = 200, square_padding: int = 25) -> dict:
    vertices = np.asarray((example["tl"], example["tr"], example["br"], example["bl"]))
    unit_square = np.asarray([
        [square_padding, square_padding],
        [square_side + square_padding, square_padding],
        [square_side + square_padding, square_side + square_padding],
        [square_padding, square_side + square_padding]
    ])
    transf = transform.ProjectiveTransform()
    if not transf.estimate(unit_square, vertices): raise Exception("estimate failed")
    cropped_np_image = transform.warp(
        np.array(example["image"]),
        transf,
        output_shape=(square_side + square_padding * 2, square_side + square_padding * 2)
    )
    cropped_image = Image.fromarray((cropped_np_image * 255).astype(np.uint8))
    return {"cropped_image": cropped_image}

dataset = datasets.load_dataset("shortery/dm-codes")
dataset = dataset.map(crop_dm_code)

DataMatrix Image Reconstruction to Enhance Decodability

This dataset is a part of the Diploma thesis <https://is.muni.cz/th/ppu25/dp-dmcodes-thesis.pdf>. This thesis compares various encoder-decoder CNNs to enhance the DM code image quality before decoding it with a code reader. The code is available on GitHub <https://github.com/shortery/dp-dm-codes>.

Citing

@thesis{dmcodes-thesis,
  author = {Petra Krátká},
  title = {DataMatrix Image Reconstruction to Enhance Decodability},
  address = {Brno},
  year = {2024},
  school = {Masaryk University, Faculty of Informatics},
  type = {Diploma thesis},
  url = {https://is.muni.cz/th/ppu25/dp-dmcodes-thesis.pdf},
}