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!
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.
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.
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>.pnginto 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-analyzerfrom 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
- 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
- Recommendation on TAP TSI Revision - Technical Document - B12
https://www.era.europa.eu/system/files/2022-10/Recommendation%20on%20TAP%20TSI%20Revision%20-%20Technical%20Document%20-%20B12.pdf
(Link not working anymore? Go to https://www.era.europa.eu/ and search for "TAP TSI Revision - Technical Document - B12")
(TAP: Telematics Applications for Passenger Service)
(TSI: Technical Specifications for Interoperability)
- UIC-barcode https://github.com/UnionInternationalCheminsdeFer/UIC-barcode (Apache License 2.0)
- Install free open source ANS.1 compiler (BSD 2)
https://github.com/vlm/asn1c
- MacOS:
brew install asn1c - Ubuntu:
apt install -y asn1c
- MacOS:
- Generate code:
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
- Interoperabilität Barcode DB Online-Ticket
https://assets.static-bahn.de/dam/jcr:8fa0c0b5-d7b8-443b-b3cd-7ae902884847/236539-315207.pdf
- Parser für Onlinetickets der Deutschen Bahn
https://github.com/rumpeltux/onlineticket (GPL 3.0) - uic-918-3
https://github.com/justusjonas74/uic-918-3 (MIT)
-
Public keys from UIC
https://railpublickey.uic.org/ -
List of numeric codes for railway companies (RICS Code)
https://uic.org/IMG/pdf/codification_4n10jun22_publi.pdf -
DB Railway Station Documentation (EVA-Nummern)
https://data.deutschebahn.com/dataset/data-haltestellen.html
-
Interoperability UIC/VDV codes, UIC918-3 and UIC918-9 example tickets and mappings for ids used in VDV codes
https://www.bahn.de/angebot/regio/barcode# Use the following command to convert PDF file into images for further processing # brew|apt install imagemagick convert -density 250 -trim -quality 100 -flatten ticket.pdf ticket.png -
DB-AGs OLT Barcode to VDV Data Structure Reference Implementation
https://sourceforge.net/projects/dbuic2vdvbc/ -
HandyTicket-Fahrausweise des VRR im VDV-Barcode
https://www.kcd-nrw.de/fileadmin/03_KC_Seiten/KCD/Downloads/Technische_Dokumente/Archiv/2010_02_12_kompendiumvrrfa2dvdv_1_4.pdf -
Additive Datenübertragung in Barcodes von internationalen Bahntickets
https://monami.hs-mittweida.de/frontdoor/deliver/index/docId/4983/file/WaitzRoman_Diplomarbeit.pdf
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.
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
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