Trusted Software Excellence across Desktop and Embedded
Take a glance at the areas of expertise where KDAB excels ranging from swift troubleshooting, ongoing consulting and training to multi-year, large-scale software development projects.
Find out why customers from innovative industries rely on our extensive expertise, including Medical, Biotech, Science, Renewable Energy, Transportation, Mobility, Aviation, Automation, Electronics, Agriculture and Defense.
High-quality Embedded Engineering across the Stack
To successfully develop an embedded device that meets your expectations regarding quality, budget and time to market, all parts of the project need to fit perfectly together.
Learn more about KDAB's expertise in embedded software development.
Where the capabilities of modern mobile devices or web browsers fall short, KDAB engineers help you expertly architect and build high-functioning desktop and workstation applications.
Extensible, Safety-compliant Software for the Medical Sector
Create intelligent, patient-focused medical software and devices and stay ahead with technology that adapts to your needs.
KDAB offers you expertise in developing a broad spectrum of clinical and home-healthcare devices, including but not limited to, internal imaging systems, robotic surgery devices, ventilators and non-invasive monitoring systems.
Building digital dashboards and cockpits with fluid animations and gesture-controlled touchscreens is a big challenge.
In over two decades of developing intricate UI solutions for cars, trucks, tractors, scooters, ships, airplanes and more, the KDAB team has gained market leading expertise in this realm.
Build on Advanced Expertise when creating Modern UIs
KDAB assists you in the creation of user-friendly interfaces designed specifically for industrial process control, manufacturing, and fabrication.
Our specialties encompass the custom design and development of HMIs, enabling product accessibility from embedded systems, remote desktops, and mobile devices on the move.
Legacy software is a growing but often ignored problem across all industries. KDAB helps you elevate your aging code base to meet the dynamic needs of the future.
Whether you want to migrate from an old to a modern GUI toolkit, update to a more recent version, or modernize your code base, you can rely on over 25 years of modernization experience.
KDAB offers a wide range of services to address your software needs including consulting, development, workshops and training tailored to your requirements.
Our expertise spans cross-platform desktop, embedded and 3D application development, using the proven technologies for the job.
When working with KDAB, the first-ever Qt consultancy, you benefit from a deep understanding of Qt internals, that allows us to provide effective solutions, irrespective of the depth or scale of your Qt project.
Qt Services include developing applications, building runtimes, mixing native and web technologies, solving performance issues, and porting problems.
KDAB helps create commercial, scientific or industrial desktop applications from scratch, or update its code or framework to benefit from modern features.
Discover clean, efficient solutions that precisely meet your requirements.
Boost your team's programming skills with in-depth, constantly updated, hands-on training courses delivered by active software engineers who love to teach and share their knowledge.
Our courses cover Modern C++, Qt/QML, Rust, 3D programming, Debugging, Profiling and more.
The collective expertise of KDAB's engineering team is at your disposal to help you choose the software stack for your project or master domain-specific challenges.
Our particular focus is on software technologies you use for cross-platform applications or for embedded devices.
Since 1999, KDAB has been the largest independent Qt consultancy worldwide and today is a Qt Platinum partner. Our experts can help you with any aspect of software development with Qt and QML.
KDAB specializes in Modern C++ development, with a focus on desktop applications, GUI, embedded software, and operating systems.
Our experts are industry-recognized contributors and trainers, leveraging C++'s power and relevance across these domains to deliver high-quality software solutions.
KDAB can guide you incorporating Rust into your project, from as overlapping element to your existing C++ codebase to a complete replacement of your legacy code.
Unique Expertise for Desktop and Embedded Platforms
Whether you are using Linux, Windows, MacOS, Android, iOS or real-time OS, KDAB helps you create performance optimized applications on your preferred platform.
If you are planning to create projects with Slint, a lightweight alternative to standard GUI frameworks especially on low-end hardware, you can rely on the expertise of KDAB being one of the earliest adopters and official service partner of Slint.
KDAB has deep expertise in embedded systems, which coupled with Flutter proficiency, allows us to provide comprehensive support throughout the software development lifecycle.
Our engineers are constantly contributing to the Flutter ecosystem, for example by developing flutter-pi, one of the most used embedders.
KDAB invests significant time in exploring new software technologies to maintain its position as software authority. Benefit from this research and incorporate it eventually into your own project.
Start here to browse infos on the KDAB website(s) and take advantage of useful developer resources like blogs, publications and videos about Qt, C++, Rust, 3D technologies like OpenGL and Vulkan, the KDAB developer tools and more.
The KDAB Youtube channel has become a go-to source for developers looking for high-quality tutorial and information material around software development with Qt/QML, C++, Rust and other technologies.
Click to navigate the all KDAB videos directly on this website.
In over 25 years KDAB has served hundreds of customers from various industries, many of them having become long-term customers who value our unique expertise and dedication.
Learn more about KDAB as a company, understand why we are considered a trusted partner by many and explore project examples in which we have proven to be the right supplier.
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications.
Read more about the history, the values, the team and the founder of the company.
When working with KDAB you can expect quality software and the desired business outcomes thanks to decades of experience gathered in hundreds of projects of different sizes in various industries.
Have a look at selected examples where KDAB has helped customers to succeed with their projects.
KDAB is committed to developing high-quality and high-performance software, and helping other developers deliver to the same high standards.
We create software with pride to improve your engineering and your business, making your products more resilient and maintainable with better performance.
KDAB has been the first certified Qt consulting and software development company in the world, and continues to deliver quality processes that meet or exceed the highest expectations.
In KDAB we value practical software development experience and skills higher than academic degrees. We strive to ensure equal treatment of all our employees regardless of age, ethnicity, gender, sexual orientation, nationality.
Interested? Read more about working at KDAB and how to apply for a job in software engineering or business administration.
QZXing is a very useful library: It provides an easy to use Qt integration API around the barcode scanning library ZXing (zebras crossing).
Because it is so easy to setup QZXing in a Qt application, we and most of our customers end up using it when they need to scan images for barcodes. There is, or rather was, a big problem though: When you want to analyze a live camera video stream, e.g. from a phone camera, the latency can easily be so large that it affects usability. The user needs to hold the camera very still on the barcode and often wait for multiple seconds until the barcode is detected.
Towards the end of last year, I decided to do something about this. At KDAB I have the freedom to spent 10% of my time on education projects. Optimizing and improving a commonly used library like QZXing also falls into this category.
The following outlines what I learned about using QZXing. I also talk a bit about the many optimizations I upstreamed to the project, which drastically improve its performance. Combined, these steps will lead to a much smoother user experience when scanning barcodes. If you have seen our Kurth KE3600 xDSL Multitester demo at Embedded World Nuremberg, you already got in direct contact with some of the fruits of this work.
Tip 1: Use a video filter
The old way to scan frames from a live video feed for barcodes was usually done
in the following way:
setup the camera to capture still images
capture an image
scan the captured image for barcodes
capture the next image
While this works, it is prohibitively slow. If you are stuck with Qt 5.4 or older - tough luck, you cannot do anything about it. If you are using a more modern version though, i.e. Qt 5.5 or higher, you can leverage Qt Multimedia video filters for scanning the frames of a live camera feed. QZXing already provides you a helpful implementation of such a filter in the form of the QZXingFilter. The QZXingLive example shows it in action and is able to analyze far more frames than the naive old approach.
Using this new approach is actually dead easy: Instantiate a QZXingFilter object, then add it to the filter list of the VideoOutput that receives the camera video stream. Then you are basically done already, as the filter contains a QZXing decoder which will notify you when a barcode was scanned:
Note that this technique will not scan every frame. Rather, it will scan frames in a background thread and ignores any frames that come in during this scan procedure. Once it has finished scanning a frame, it will pick up the next frame and so forth. For the user experience, it is thus still important to scan a single frame as quickly as possible, such that we can find the barcode easily. After all, the more frames you are able to scan per second, the higher the chances that you scan a frame with a readable version of the barcode on it.
Tip 2: Explicitly set the list of expected codecs
The fastest code is code that does not run. A quick way to speed the scan process up is to tell ZXing what kind of barcodes you expect. In all cases I have worked on so far, you usually expect one or two 1D barcode types and 2D QR codes:
If you explicitly only enable those types, scanning of frames where no barcode can be found is going to be significantly faster. Otherwise, ZXing will hopelessly iterate linearly over all enabled codecs, which can accumulate a significant overhead.
Tip 3: Reduce the amount of frame data
I have added a new feature to the QZXingFilter - the capture rect. It allows you to limit the barcode scan to parts of a frame. The QZXingLive example shows this in action:
Only the area shaded in red will be scanned for barcodes. In this case, it is only 1/4 of the actual frame size, which means that ZXing also only has to inspect 1/4 of the pixels in the frame. This obviously makes the process much faster. On my desktop machine, I can scan 1920x1080 frames at about 42fps with the capture rect. If I use the full frame instead, the frame rate drops to ca. 26fps.
Setting up the capture rect can be somewhat tricky, as you need to use the camera source coordinate system. Use the mapping functions of VideoOutput for this purpose, but don't forget to manually setup the bindings to thesourceRect and contentRect, otherwise the captureRect may not get updated properly:
QZXingFilter{captureRect:{// setup bindings videoOutput.contentRect; videoOutput.sourceRect;// only scan the central quarter of the area for a barcode return videoOutput.mapRectToSource(videoOutput.mapNormalizedRectToItem(Qt.rect(
0.25, 0.25, 0.5, 0.5
)));}
Tip 4: Use a good camera
Scanning barcodes, especially 1D barcodes, can become quite hard when your camera only produces blurry images of low quality. The better your camera, the easier it will be to find barcodes. Most cheap consumer webcams do not support autofocus for example, which negatively influences the detection speed. Also, do not forget to enable autofocus on your camera!
I have often observed that the overall time to scan a barcode is faster on my Android phone compared to my beefy desktop machine. When you look at the time to scan a single frame, the opposite is true - the desktop machine can scan roughly six times as many frames per second than my phone. But once you inspect the image quality of the two respective cameras, the reason is quite obvious - the desktop tries to find barcodes in blurry unfocused screens with bad contrast. This often means that the scan algorithms fail, especially when you deal with 1D barcodes. The phone images on the other hand are much sharper, and have good contrast between the individual bars.
Tip 5: Optimize and improve QZXing
This tip is more a collection of things that I improved upstream. Thankfully QZXing is an open source project, which means everyone can improve it. I think there are more areas that could be improved, so consider this also as a motiviation to start hacking on QZXing to improve it for everyone that is using it.
I started off by profiling QZXing with Linux perf. It directly pointed me at many hotspots in QZXingLive which resulted in low per-frame performance. The reason was mostly due to repeated copies of the frame data. Initially the following happened when we scanned a frame:
frame data is copied to be able to process it in a background thread
data is converted into a QImage compatible format, often incurring undesired copies to the original frame data
the image is scaled to not exceed the maximum size of 999x999, which not only copies the data, it also reduces the quality of the image that will be scanned
the scaled image data is copied into a ArrayRef<byte> matrix class, such that ZXing can analyze its contents
this matrix is copied once more, for good measure
when no barcode was found, the next frame mirrors the image data (which again copies) before handing it off to ZXing. This is done in order to scan cameras also when the input image is rotated, but very negatively influences latency by up to three frames, since the image is first mirrored horizontally, then vertically, and then in both direction
You can imagine that this is not optimal. Actually, this situation was so bad that I can only explain it in one way: This code was never run through a real profiler.
Profiling C++ code can be extremely hard. But when you know what tools to use and how to interpret their results, it is a very rewarding job. And when you do it before anyone else, chances are high that you will find many code paths that are easy to fix! If you want to learn more about profiling, consider attending our Debugging and Profiling for Qt Developers training.
I used a combination of Linux perf and heaptrack and optimized the QZXingLive code in a series of patches that got upstreamed in January. With a recent version of QZXingLive, performance is much better and we have copy the frame data less often:
the data is still copied to be able to process it in the background thread
the data is directly and efficiently converted into a grayscale QImage
this image is then copied into the ArrayRef<byte> matrix and analyzed in its original resolution
if no barcode was found, and only if the tryHarder flag is set to true on the decoder, we flip the image directly and try again without waiting for the next frame
With some more effort, we should be able to get rid of the QImage in the middle, removing another copy of the data. I did not go down that route, because QZXingLive is now at a level that it performs well enough for my needs even on slower mobile devices.
While writing this report, I realized that I back then concentrated only on the performance on an iOS device that supplied RGB frames. On my desktop machine, I get YUV420p frames. The conversion step into a grayscale image for these frames did not yet take the capture rect into account, leading to unnecessary copying. Fixing this part improves QZxingLive frame decoding time from ~25ms down to ~16ms on my machine.
Summary
I hope you learned how to use QZXing effectively in your project. Remember to use the QZXingFilter class for efficient decoding of a live video stream. And also remember to profile your code. Copying data around needlessly, esp. on the heap, can be an extremely costly operation and should always be prevented if at all possible.
Finally, i would like to share that the next step of the library is to support barcode encoding. I expect the QR encoding to be ready within the coming month which is the target for the creation of QZXing's release v3.0.
Best regards and keep up the good work!
25 - Apr - 2017
Milian Wolff
Excellent, this is good news! And again, many thanks for providing QZXing, it's an extremely useful library.
7 - Oct - 2017
Elsiete
Awesome work, thumbs up.
24 - Nov - 2017
Zaki
How can do that with Qt c++ ?
25 - Nov - 2017
Milian Wolff
You cannot, I'm afraid to say. The video filter API is currently only used by the Qt Quick Qt Multimedia backend.
12 - Feb - 2018
Nikolaos Ftylitakis
I would like to let you know that the QR Code encoding functionality has just been made available.
You are welcomed to give it a try.
My camera takes blurry photos. I use the code that you mentioned about auto focus but nothing happens. Any suggestions?
23 - Sept - 2019
Milian Wolff
No, sorry - I've seen the same happening with some cheap webcams. The only solution I found was using a better camera, really.
23 - Sept - 2019
NickVr88
I use a huawei p9 lite. Camera is good but still nothing. The same happens also with samsung s4.
23 - Sept - 2019
Milian Wolff
Then I'm afraid to say that you'll have to debug it yourself. I have not seen such an issue the last time I tried this myself with a phone camera.
26 - Feb - 2020
Song
Hi,
I found it is very hard to decode some vague images, but other apps can decode those images easily.
How to improve it?
2 - Mar - 2020
Milian Wolff
I suggest you ask on the ZXing mailing list - this isn't directly related to this blog post nor QZXing either.
Some generic suggestions:
enable autofocus
run some preprocessing steps on the input image, like sharpen etc.
get a better camera
9 - May - 2022
Abiyot Dilbeto Miesso
Interesting
Milian Wolff
Senior Software Engineer
Milian Wolff has a long history of creating tools for C++ developers. He’s the main author of Massif-Visualizer, heaptrack, hotspot and ctf2ctf tools now used widely to improve C++ applications performance. He’s a Senior Software Engineer at KDAB where he enjoys solving hard performance problems and teaching developers about debugging and profiling tools. Milian has a Masters Degree in Physics.
Our hands-on Modern C++ training courses are designed to quickly familiarize newcomers with the language. They also update professional C++ developers on the latest changes in the language and standard library introduced in recent C++ editions.
14 Comments
25 - Apr - 2017
Nikolaos Ftylitakis
Hello Milian and thank you very much for this insightful article.
Your contribution has been very useful and i am sure everyone will benefit from the changes.
I just wanted to make a quick note. In the QZXingFilter, when "tryHarder" is set, it no longer make copies the QImage and retry(https://github.com/ftylitak/qzxing/commit/572bd586c368413a22242387598a3cbcd0852a9b)). This is because QZXing already handles the image flipping and rotation internally for retries.
Finally, i would like to share that the next step of the library is to support barcode encoding. I expect the QR encoding to be ready within the coming month which is the target for the creation of QZXing's release v3.0.
Best regards and keep up the good work!
25 - Apr - 2017
Milian Wolff
Excellent, this is good news! And again, many thanks for providing QZXing, it's an extremely useful library.
7 - Oct - 2017
Elsiete
Awesome work, thumbs up.
24 - Nov - 2017
Zaki
How can do that with Qt c++ ?
25 - Nov - 2017
Milian Wolff
You cannot, I'm afraid to say. The video filter API is currently only used by the Qt Quick Qt Multimedia backend.
12 - Feb - 2018
Nikolaos Ftylitakis
I would like to let you know that the QR Code encoding functionality has just been made available. You are welcomed to give it a try.
12 - Feb - 2018
Nikolaos Ftylitakis
How to use: https://github.com/ftylitak/qzxing#howToEncoding
Example project: https://github.com/ftylitak/qzxing/tree/master/examples/BarcodeEncoder
Looking forward to your feedback!
23 - Sept - 2019
NickVr88
My camera takes blurry photos. I use the code that you mentioned about auto focus but nothing happens. Any suggestions?
23 - Sept - 2019
Milian Wolff
No, sorry - I've seen the same happening with some cheap webcams. The only solution I found was using a better camera, really.
23 - Sept - 2019
NickVr88
I use a huawei p9 lite. Camera is good but still nothing. The same happens also with samsung s4.
23 - Sept - 2019
Milian Wolff
Then I'm afraid to say that you'll have to debug it yourself. I have not seen such an issue the last time I tried this myself with a phone camera.
26 - Feb - 2020
Song
Hi, I found it is very hard to decode some vague images, but other apps can decode those images easily. How to improve it?
2 - Mar - 2020
Milian Wolff
I suggest you ask on the ZXing mailing list - this isn't directly related to this blog post nor QZXing either.
Some generic suggestions:
9 - May - 2022
Abiyot Dilbeto Miesso
Interesting