当前位置:网站首页>条形码识别性能低,如何优化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
边栏推荐
- 2020-08-17:详细说下数据倾斜怎么解决?
- Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
- Detect certificate expiration script
- Application insights application insights use application maps to build request link views
- Epu360: all the H5 templates you want are here, e-book, big turntable, red envelope rain, questionnaire survey
- 如何才能快速正确的部署甘特图
- Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
- 2020-08-17: how to solve data skew in detail?
- #JVM 类加载机制
- 2020-08-14:数据任务的执行引擎用的哪些?
猜你喜欢
The isolation level of transaction and its problems
[elastic search engine]
2020-08-17:详细说下数据倾斜怎么解决?
Cloudquery v1.2.0 release
Erd-online free online database modeling tool
Utility class functions (continuous update)
Common syntax corresponding table of mongodb and SQL
打工人好物——磨炼钢铁意志就要这样高效的电脑
A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
What kind of music do you need to make for a complete game?
随机推荐
A good thing for working people -- to temper the will of iron and steel requires such an efficient computer
[elastic search engine]
The native API of the future trend of the front end: web components
10000! Ideal car recalls all defective cars: 97 accidents have occurred and losses will be expanded
【涂鸦物联网足迹】物联网基础介绍篇
甘特图对活动进行分组教程
Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
心理咨询app开发所具备的优点与功能
In 2020, how can wechat seal numbers be quickly lifted?
Using iceberg on kubernetes to create a new generation of cloud original data Lake
【涂鸦物联网足迹】涂鸦云平台全景介绍
Message queue - Analysis
如何才能快速正确的部署甘特图
2020-08-14:数据任务的执行引擎用的哪些?
1万辆!理想汽车召回全部缺陷车:已发生事故97起,亏损将扩大
WebAPI接口设计:SwaggerUI文档 / 统一响应格式 / 统一异常处理 / 统一权限验证
Introduction to the development of small game cloud
Mongo user rights login instruction
Exclusive interview of guests at | 2020 PostgreSQL Asia Conference: Wang Tao
超高频RFID医疗血液管理系统应用