| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Provide optimized and robust methods to detect and decode aztec-codes by using opencv and zxing-cpp in combination and to transcode UIC918 information with signature validation into json structure. (UIC918-3 and UIC918-9)
Looking for build instructions? Take a look at the end of this document!
A command line tool to detect and decode uic918 content from aztec-codes from given input images/pdfs or raw data, verifies content and prints json result on stdout or dumps it into file.
Check ticket-decoder --help for arguments.
Example:
build/Release/bin/ticket-decoder -i ~/my-ticket.pdf
Install from pypi.org using:
pip install ticket-decoder
For more details about usage see here: README
Prefer using the official module, but when you want to build the module locally, the following steps should work:
export CMAKE_POLICY_VERSION_MINIMUM=3.5 # To make easyloggingcpp building properly using a quite old minimum cmake version uv build --wheel uv venv uv pip install dist/ticket_decoder*.whl uv run python ...
When the module has been built und installed successfully, it should be possible to execute the following minimal Python script:
from ticket_decoder import DecoderFacade
decoder_facade = DecoderFacade()
print(decoder_facade.decode_files('path/2/your/ticket.pdf'))
Analyzer has a minimal UI and is able to scan for aztec-codes in images grabbed from camera or from images/pdfs in 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 (detector implementations).
Check ticket-analyzer --help for arguments.
To get a minimal setup for experimentation, do the following:
This step is required only when the UIC specificatation gets updated and the change is relevant for the information used from the barcode details. This should not happen that often.
# Clones the repository and calls asn1c with matching parameters at the right places # ./etc/generate-uic-asn1-pods.sh
Place XML file containing public keys from UIC at default location
cert/UIC_PublicKeys.xml
Place LDIF export file containing public certificates from VDV at default location
cert/VDV_Certificates.ldif
List of numeric codes for railway companies (RICS Code)
https://uic.org/support-activities/it/rics
DB Railway Station Documentation (EVA/IBNR-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
Some public technical documents about VDV-Kernapplikation (VDV-KA) and sample tickets using UIC and VDV standards
https://www.kcd-nrw.de/service/downloads/technische-dokumente.html
You can use the following command to convert PDF file into images for further processing if you want, but you don't have to because the application is able to precess pdf files directly. But decoding quality might differ depending on parameters like DPI, so when you want to play with that...
# brew|apt install imagemagick convert -density 250 -trim -quality 100 -flatten <file name>.pdf <file name>.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
KDE Barcode Formats - Ticket Barcode Formats
https://community.kde.org/KDE_PIM/KItinerary/Barcode_Formats
Some details and collection of links related to different european rail companies and their ticket formats.
It is possible to enable/disable parts of the application or the Python module to avoid the massive dependencies coming in with some features (e.g. the user interface for ticket-analyzer). The following conan options (feature flags) are available:
To enable/disable, please use prepared scripts like setup.Decoder.sh and change desired feature toggles there. Or pass options like -o:a="&:with_ticket_analyzer=False" to conan install script. Check the script mentioned above as a guideline.
Following libraries are used by the project. Usually you should not care about it since conan package manager will do that for you.
Workaround for poppler: since the official version of this library on conancenter is quite old, poppler is built locally via conan but with own recipe to get minimal and up-to-date version: see etc/poppler/conanfile.py. Library creation is integrated in etc/conan-install.sh script which is called from common setup scripts automatically.
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.py 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.
This will install dependencies and run the build inside a ubuntu docker build container
When the preparation of the build environment has been successful, it should be possible to build the project by using ./build.sh -j3 inside the build container. (When your container environment has enough memory, you can try ./build.sh as well. But often this leads to out-of-memory-errors due to lots of files getting compiled in parallel and the container environment is killing the compilers when they reach the memory limit.)
Take a look into ./build/ folder to discover artifacts. You should be able to execute the executables on host machine as well when it runs the same OS.
When opencv has to be built from source because of missing pre-built package for your arch/os/compiler/config mix, it might be necessary to install some further xorg/system libraries to make highgui stuff building inside conan install process. To get this handled automatically, use the conan config flags shown below in ~/conan2/profiles/default or pass additional argument -pr:a="./etc/conan/profiles/package-manager-config" to conan-install call in setup.All.sh.
[conf] tools.system.package_manager:mode=install tools.system.package_manager:sudo_askpass=True
Otherwise, please install required xorg dependencies manually. For details about specific required packages, please check the error message carefully and/or check etc/install-ubuntu-dependencies.sh for a list of dev-package names.
apt-get install --no-install-recommends -y build-essential cmake git wget python-is-python3 python3-pip python3-dev libgtk2.0-dev ./etc/install-ubuntu-dependencies.sh git clone https://github.com/user4223/ticket-decoder.git && cd ticket-decoder python3 -m venv venv . venv/bin/activate pip install -r requirements.txt ./setup.All.sh cert/install-uic-keys.sh build/Release/bin/ticket-decoder-test etc/python-test.sh
It might be required for dependencies to get built properly during conan install to have a python command (without 3) in path available. So when you face an error like python: command not found it might be required to create a link via sudo ln -s $(which python3) /usr/local/bin/python since there is no package python-is-python3 in homebrew available, as it is for ubuntu. Verify your $PATH environment variable to ensure python interpreter is taken from /usr/local/bin for the shell you are using.
xcode-select --install brew install cmake git clone https://github.com/user4223/ticket-decoder.git && cd ticket-decoder python -m venv venv . venv/bin/activate pip install -r requirements.txt ./setup.All.sh cert/install-uic-keys.sh build/Release/bin/ticket-decoder-test etc/python-test.sh
For sure, it should be possible to get it built by using visual compiler and toolchain as well. But I never tried and you might need to modify some build parameters/arguments and you have know (or to find out) how to setup toolchain, conan and cmake in Windows environment. Furthermore, the compiler might complain about things gcc and clang are not complaining about. Pull request welcome!
| Back | FazBrowse Home | New Git URL |