当前位置:网站首页>How to optimize the decoding performance of dynamsoft barcode reader
How to optimize the decoding performance of dynamsoft barcode reader
2020-11-06 22:28:00 【roffey】
Dynamsoft Barcode Reader SDK A multifunctional barcode reading control , It only needs a few lines of code to embed the barcode reading function into Web Or desktop applications . This can save months of development time and cost . It can support multiple image file formats as well as those obtained from cameras or scanners DIB Format . Use Dynamsoft Barcode Reader SDK, You can create powerful and practical barcode scanner software , To meet your business needs .
Click to download Dynamsoft Barcode Reader The latest version
Many companies like to use Dynamsoft Barcode Reader SDK, Because it has flexible parameter configuration and powerful decoding ability for multiple barcodes . In this paper , Let's take a look at the bar code SDK Templates and possible ways to optimize decoding performance from a developer's point of view .
How to configure the template for decoding performance
If you've never tried Dynamsoft Barcode Reader SDK, You can play in the online bar code playground , Just change the mode to directly compare performance differences .
Besides , If you're an expert , You can click Advanced settings to adjust a series of parameters .
For the convenience of developers , I asked Github Five useful template files have been uploaded :
- Speed.json
- Balanced.json
- Coverage.json
- Morecoverage.json
- Mostcoverage.json
Decoding speed or decoding accuracy ? You can weigh the trade-offs , It depends on the specific usage scheme .
This is my test image :
Let's look at the detection accuracy and time cost of using different templates :
BarcodeReader.exe AllSupportedBarcodeTypes.png license.txt speed.json
Total barcode(s) found: 12. Time cost: 63 ms
BarcodeReader.exe AllSupportedBarcodeTypes.png license.txt balanced.json
Total barcode(s) found: 13. Time cost: 140 ms
BarcodeReader.exe AllSupportedBarcodeTypes.png license.txt coverage.json
Total barcode(s) found: 13. Time cost: 844 ms
BarcodeReader.exe AllSupportedBarcodeTypes.png license.txt morecoverage.json
Total barcode(s) found: 13. Time cost: 1610 ms
BarcodeReader.exe AllSupportedBarcodeTypes.png license.txt mostcoverage.json
Total barcode(s) found: 13. Time cost: 3156 ms
As far as I'm concerned , To ensure the accuracy and decoding speed , The most appropriate template is balance.json.
Can multithreading speed up the performance of multi barcode decoding ?
According to our common sense , The time cost of decoding a single barcode should be less than that of decoding multiple barcodes . therefore , One possible optimization for reading multiple barcodes is to create multiple worker threads , To process different barcode symbols at the same time .
This is the code used to decode one-dimensional and two-dimensional barcodes in sequence :
barcode_decoding(buffer, size, BF_CODE_39, 1, license, config);
barcode_decoding(buffer, size, BF_QR_CODE, 1, license, config);
barcode_decoding(buffer, size, BF_PDF417, 1, license, config);
barcode_decoding(buffer, size, BF_DATAMATRIX, 1, license, config);
The total time cost is 407 millisecond :
Thread id: 22536. Type: CODE_39
Thread id: 22536. Total barcode(s) found: 1. Time cost: 235 ms
Thread id: 22536. Type: QR_CODE
Thread id: 22536. Total barcode(s) found: 1. Time cost: 47 ms
Thread id: 22536. Type: PDF417
Thread id: 22536. Total barcode(s) found: 1. Time cost: 62 ms
Thread id: 22536. Type: DATAMATRIX
Thread id: 22536. Total barcode(s) found: 1. Time cost: 63 ms
In order to optimize decoding performance , I can create four threads to perform the same operation :
int starttime = gettime();
thread t1(barcode_decoding, buffer, size, BF_CODE_39, 1, license, config);
thread t2(barcode_decoding, buffer, size, BF_QR_CODE, 1, license, config);
thread t3(barcode_decoding, buffer, size, BF_PDF417, 1, license, config);
thread t4(barcode_decoding, buffer, size, BF_DATAMATRIX, 1, license, config);
t1.join();
t2.join();
t3.join();
t4.join();
int endtime = gettime();
printf("Thread time cost: %d ms\n\n", (endtime - starttime));
The final time cost is 265 millisecond :
Thread id: 24024. Type: QR_CODE
Thread id: 24024. Total barcode(s) found: 1. Time cost: 78 ms
Thread id: 17384. Type: DATAMATRIX
Thread id: 17384. Total barcode(s) found: 1. Time cost: 78 ms
Thread id: 24264. Type: PDF417
Thread id: 24264. Total barcode(s) found: 1. Time cost: 94 ms
Thread id: 4060. Type: CODE_39
Thread id: 4060. Total barcode(s) found: 1. Time cost: 265 ms
Thread time cost: 265 ms
up to now , It seems pretty good . however , If you pass multiple barcode types to Dynamsoft Barcode decoding API, Then something magical will happen :
barcode_decoding(buffer, size, BF_CODE_39 | BF_DATAMATRIX | BF_QR_CODE | BF_PDF417, 1, license, config);
It's faster than your own multithreading solution :
Thread id: 20308. Type: PDF417
Thread id: 20308. Type: QR_CODE
Thread id: 20308. Type: DATAMATRIX
Thread id: 20308. Type: CODE_39
Thread id: 20308. Total barcode(s) found: 4. Time cost: 250 ms
The reason is that all of Dynamsoft Barcode decoding API Both are implemented in threads . therefore , You don't need to create threads to optimize decoding performance .
How does the number of threads affect Dynamsoft Barcode SDK performance ?
You may have noticed , There is one named maxAlgorithmThreadCount Parameters of . We can improve by increasing the number of threads SDK Performance ?
I did a simple test based on the hardware thread :
const auto processor_count = std::thread::hardware_concurrency();
int minimum_count = 1, minimum_timecost = 0;
for (int i = 0; i < processor_count; i++)
{
printf("Thread count: %d. ", i + 1);
int timecost = barcode_decoding(buffer, size, formats, i, license, config);
if (i == 0)
{
minimum_count = 1;
if (timecost > 0)
{
minimum_timecost = timecost;
}
}
else {
if (timecost < minimum_timecost)
{
minimum_count = i + 1;
minimum_timecost = timecost;
}
}
}
printf("Multi-thread best performance: thread_count = %d, timecost = %d \n\n", minimum_count, minimum_timecost);
Every time I run the app , We'll get different results . By using my test images , There is no significant difference in performance :
Thread count: 1. Thread id: 26376. Total barcode(s) found: 13. Time cost: 141 ms
Thread count: 2. Thread id: 26376. Total barcode(s) found: 13. Time cost: 141 ms
Thread count: 3. Thread id: 26376. Total barcode(s) found: 13. Time cost: 125 ms
Thread count: 4. Thread id: 26376. Total barcode(s) found: 13. Time cost: 140 ms
Thread count: 5. Thread id: 26376. Total barcode(s) found: 13. Time cost: 157 ms
Thread count: 6. Thread id: 26376. Total barcode(s) found: 13. Time cost: 203 ms
Thread count: 7. Thread id: 26376. Total barcode(s) found: 13. Time cost: 156 ms
Thread count: 8. Thread id: 26376. Total barcode(s) found: 13. Time cost: 140 ms
Multi-thread best performance: thread_count = 3, timecost = 125
obviously , A test image doesn't make any sense . Ideally , You should use image datasets to measure performance . therefore , If you are interested , Do it now .
This article is reprinted from 【 Huidu technology 】. Any reprint is welcome , But be sure to indicate the source 、 Do not modify the original link , Respect for the work of others
版权声明
本文为[roffey]所创,转载请带上原文链接,感谢
边栏推荐
- Composition of MRAM cache
- How to create an interactive kernel density chart
- Mongo user rights login instruction
- The 4th China BIM (digital construction) manager Summit Forum will be held in Hangzhou in 2020
- C calls SendMessage to refresh the taskbar icon (the icon does not disappear at the end of forcing)
- 应用层软件开发教父教你如何重构,资深程序员必备专业技能
- C and C / C + + mixed programming series 5 - GC collaboration of memory management
- 迅为-iMX6ULL开发板上配置AP热点
- September 3, 2020: naked writing algorithm: loop matrix traversal.
- A concise tutorial for Nacos, ribbon and feign
猜你喜欢
ado.net and asp.net The relationship between
JS string - string string object method
[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!
The essence of transaction and the principle of deadlock
September 3, 2020: naked writing algorithm: loop matrix traversal.
Unexpected element.. required element
如何使用甘特图图层和筛选器
Nodejs中使用jsonwebtoken(JWT)生成token的场景使用
How to manage the authority of database account?
C calls SendMessage to refresh the taskbar icon (the icon does not disappear at the end of forcing)
随机推荐
Composition of MRAM cache
How does varhart xgantt represent working days on a calendar
#JVM 类加载机制
轻量型 GPU 应用首选 京东智联云推出 NVIDIA vGPU 实例
[forward] how to view UserData in Lua
MRAM高速缓存的组成
DC-1 target
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
2020-09-04: do you understand the function call convention?
Windows 10 蓝牙管理页面'添加蓝牙或其他设备'选项点击无响应的解决方案
The method of local search port number occupation in Windows system
Stm32f030f4p6 compatible with smart micro mm32f031f4p6
Nanjing logo design and production, guide VI system design
Git remote library rollback specified version
南京标识标牌设计制作,导视VI系统设计
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
Zhou Jie: database system of East China Normal University
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
Google browser realizes video playback acceleration function
Configuration of AP hotspot on xunwei-imx6ull development board