Skip to content

Provide optimized and robust methods to detect and decode aztec codes by using opencv and zxing-cpp in combination and to transcode UIC918 information into json structure

License

Notifications You must be signed in to change notification settings

jdw1023/ticket-decoder

 
 

Repository files navigation

build

Overview

Provide optimized and robust methods to detect and decode aztec codes by using opencv and zxing-cpp in combination with signature validation and to transcode UIC918 information into json structure.
Looking for build instructions? Take a look at the end of this document or check .github/workflows/c-cpp.yml!

ticket-decoder

Decoder can detect and decode uic918 content from aztec codes from given input images, verifies content and prints json result on stdout or dumps it into file.

ticket-decoder

ticket-analyzer

Analyzer is able to scan for aztec codes in images grabbed from camera or from a folder. It provides a simple interactive mode to visualize detection, image processing and decoding steps and to change some parameters to find optimal setup for detection. This application is considered to optimize default parameters and algorithms for the decoder.

ticket-analyzer

To get a minimal setup for experimentation, do the following:

  • Download UIC918-3 and UIC918-9 sample tickets from https://www.bahn.de/angebot/regio/barcode and extract zip files into folder ./images/
  • Install imagemagick and navigate with terminal emulator into ./images/ folder
  • Convert pdf files via convert -density 250 -trim -quality 100 -flatten <file name>.pdf <file name>.png into image files
  • Download XML file containing public keys of issuers from https://railpublickey.uic.org/ into folder ./cert/ and name it UIC_PublicKeys.xml
  • Run ./ticket-analyzer from workspace folder or use arguments to specify different paths to input files and folders
  • Use following keys to tweak settings:
    • i: Visualize next image processing step
    • I: Visualize previous image processing step
    • c: Visualize next contour detection step
    • C: Visualize previous contour detection step
    • f: Next image input file from image-folder
    • F: Previous image input file from image-folder (0 uses camera device)
    • r: Rotate image -1 degree
    • R: Rotate image +1 degree
    • 2: Split image into 2 parts and rotate over parts
    • 4: Split image into 4 parts and rotate over parts
    • s: Scale up image
    • S: Scale down image
    • 0: Reset: Rotation, Scale, Split
    • d: Rotate over available detector implementations
    • p: Assume pure barcode
    • b: Use local average binarizer
    • D: Dump current image into output-folder
    • o: Overlay detected barcode image
    • t: Overlay decoded content or text
  • Check output-folder for intermediate images, raw data files or decoded data in json files

Considerations about optical Resolution

  • Printed code size: 48mm (1.89inch)
  • With 200dpi: 1.89 inch/code * 200 dot/inch ~ 380 dot/code
  • With UIC-918-3: 380 dot / 87 blocks ~ 4.37 dot/block

Record Documentation

U_HEAD / U_TLAY / U_FLEX

Code generation for U_FLEX ASN.1 UPER

pushd etc
git clone https://github.com/UnionInternationalCheminsdeFer/UIC-barcode
popd

pushd source/lib/uic918/gen/v1.3
asn1c -fcompound-names -fwide-types -gen-PER ../../../../../etc/UIC-barcode/misc/uicRailTicketData_v1.3.3.asn
rm converter-sample.c
popd

0080VU

0080BL

Signature Checking / Id-Mapping

Further Documentation and Ticket Samples

Build Instructions

In general, when you want to avoid to install additional dependencies like non-default compilers and libraries on your system, consider using one of the build scripts using a docker container to create the build environment.
As long as the conanfile.txt is unchanged, you can re-use the container with pre-built dependencies, source code changes are directly mirrored into build environment and artifacts are mirrored back into host system. In case dependencies change, the container gets re-build with updated dependencies.

  • setup.ubuntuJammy.gcc11.Release.sh
  • setup.ubuntuJammy.clang15.Release.sh

When the preparation of the build environment has been successful, it should be possible to build the project by using ./build.sh -j inside the build container.

Ubuntu jammy

Take a look into one of the following docker files to see minimal required dependencies and the instructions to prepare the build environment in case you want to build the project without a build container.

  • etc/ubuntuJammy.gcc11.Release.Dockerfile
  • etc/ubuntuJammy.clang15.Release.Dockerfile

MacOS with Apple clang14

xcode-select --install

pip install conan==1.59.0
conan profile new --detect --force ticket-decoder
conan profile update settings.compiler.version=14.0 ticket-decoder

git clone https://github.com/karlheinzkurt/ticket-decoder.git
cd ticket-decoder
./setup.Release.sh -j

wget 'https://railpublickey.uic.org/download.php' -O cert/UIC_PublicKeys.xml
build/Release/bin/ticket-decoder-test

About

Provide optimized and robust methods to detect and decode aztec codes by using opencv and zxing-cpp in combination and to transcode UIC918 information into json structure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 94.8%
  • CMake 2.4%
  • Dockerfile 1.1%
  • Shell 1.1%
  • Python 0.6%