|
--- |
|
dataset_info: |
|
features: |
|
- name: image |
|
dtype: image |
|
- name: tl |
|
sequence: int64 |
|
- name: tr |
|
sequence: int64 |
|
- name: br |
|
sequence: int64 |
|
- name: bl |
|
sequence: int64 |
|
- name: is_clean |
|
dtype: bool |
|
- name: split |
|
dtype: string |
|
- name: text |
|
dtype: string |
|
- name: image_name |
|
dtype: string |
|
splits: |
|
- name: validation |
|
num_bytes: 64018244 |
|
num_examples: 101 |
|
- name: test |
|
num_bytes: 125460818 |
|
num_examples: 199 |
|
download_size: 189448472 |
|
dataset_size: 189479062 |
|
configs: |
|
- config_name: default |
|
data_files: |
|
- split: validation |
|
path: data/validation-* |
|
- split: test |
|
path: data/test-* |
|
license: mit |
|
task_categories: |
|
- image-to-text |
|
- object-detection |
|
size_categories: |
|
- n<1K |
|
--- |
|
|
|
# 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}, |
|
} |
|
``` |