当前位置:网站首页>条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
2020-11-06 22:28:00 【roffey】
Dynamsoft Barcode Reader SDK一款多功能的条码读取控件,只需要几行代码就可以将条码读取功能嵌入到Web或桌面应用程序。这可以节省数月的开发时间和成本。能支持多种图像文件格式以及从摄像机或扫描仪获取的DIB格式。使用Dynamsoft Barcode Reader SDK,你可以创建强大且实用的条形码扫描仪软件,以满足你的业务需求。
点击下载Dynamsoft Barcode Reader最新版
许多企业喜欢使用Dynamsoft Barcode Reader SDK,因为它具有灵活的参数配置和强大的对多个条形码的解码能力。在本文中,让我们看一下条形码SDK模板以及从开发人员的角度优化解码性能的可能方法。
如何配置用于解码性能的模板
如果您从未尝试过Dynamsoft Barcode Reader SDK,则可以在在线条形码游乐场玩耍,只需更改模式即可直接比较性能差异。
此外,如果您是专家,则可以单击高级设置自行调整一系列参数。
为了方便开发人员,我向Github上传了五个有用的模板文件:
- Speed.json
- Balanced.json
- Coverage.json
- Morecoverage.json
- Mostcoverage.json
解码速度还是解码精度?您可以权衡取舍,具体取决于特定的使用方案。
这是我的测试图像:
我们来看一下使用不同模板的检测准确性和时间成本:
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
就我而言,要保证准确性和解码速度,最合适的模板是balance.json。
使用多线程可以加快多条形码解码的性能吗?
按照我们的常识,解码单个条形码的时间成本应小于解码多个条形码的时间成本。因此,读取多个条形码的一种可能的优化方法是创建多个工作线程,以同时处理不同的条形码符号。
这是用于顺序解码一维和二维条形码的代码:
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);
总时间成本为407毫秒:
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
为了优化解码性能,我可以创建四个线程来执行相同的操作:
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));
最终时间成本为265毫秒:
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
到目前为止,似乎还不错。但是,如果将多种条形码类型传递给Dynamsoft条形码解码API,则会发生神奇的事情:
barcode_decoding(buffer, size, BF_CODE_39 | BF_DATAMATRIX | BF_QR_CODE | BF_PDF417, 1, license, config);
它比您自己的多线程解决方案快:
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
原因是所有Dynamsoft条形码解码API均在线程中实现。因此,您无需创建线程来优化解码性能。
线程数如何影响Dynamsoft Barcode SDK性能?
您可能已经注意到,有一个名为maxAlgorithmThreadCount的参数。我们可以通过增加线程数来提高SDK性能吗?
我根据硬件线程做了一个简单的测试:
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);
每次我运行该应用程序时,都会得到不同的结果。通过使用我的测试图像,性能没有显着差异:
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
显然,一张测试图像没有任何意义。理想情况下,您应该使用图像数据集来衡量性能。因此,如果您有兴趣,现在就去动手吧。
本文章转载自【慧都科技】。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,尊重他人劳动成果
版权声明
本文为[roffey]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4587239/blog/4484530
边栏推荐
- ado.net and asp.net The relationship between
- Code generator plug-in and creator preform file analysis
- Unexpected element.. required element
- Common mathematical basic formulas of recursive and backtracking algorithms
- 实验一
- Composition of MRAM cache
- Zhou Jie: database system of East China Normal University
- 大佬们如何在nginx镜像里面增加模块?
- [learning] interface test case writing and testing concerns
- 2020-08-18:介绍下MR过程?
猜你喜欢
VARCHART XGantt如何在日历上表示工作日
Introduction to the development of small game cloud
2020-08-29: process thread differences, in addition to the inclusion relationship, the underlying details?
Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
Design of NAND flash interface control
心理咨询app开发所具备的优点与功能
2020-08-15:什么情况下数据任务需要优化?
Nodejs中使用jsonwebtoken(JWT)生成token的场景使用
Detect certificate expiration script
A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
随机推荐
NAND FLASH的接口控制设计
Unexpected element.. required element
移动端像素适配方案
非易失性MRAM存储器应用于各级高速缓存
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
20 XR projects roadshows, nearly 20 capital institutions attended! We sincerely invite you to attend the 2020 qcomm XR eco Partner Conference
2020年新规,微信封号怎么快速解除?
Using iceberg on kubernetes to create a new generation of cloud original data Lake
How to start the hidden preferences in coda 2 on the terminal?
September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.
VARCHART XGantt入门教程
Zhou Jie: database system of East China Normal University
How to add modules to nginx image?
2020-08-19: what mechanism does TCP ensure reliability?
Qt音视频开发46-视频传输UDP版
Practice of Xiaoxiong school development board: real equipment access of smart street lamp sandbox experiment
Event monitoring problem
Python 100 cases
Two dimensional code location and alarm system of Expressway
The essence of transaction and the principle of deadlock