当前位置:网站首页>条形码识别性能低,如何优化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
边栏推荐
- To solve the problem that the data interface is not updated after WPF binding set
- win7 APPCRASH(解决方法)(转)
- 2020-08-19:TCP是通过什么机制保障可靠性的?
- 迅为-iMX6ULL开发板上配置AP热点
- Why is the LS command stuck when there are too many files?
- Empty test suite appears in JUnit test
- Using JSON webtoken (JWT) to generate token in nodejs
- Composition of MRAM cache
- August 24, 2020: what are small documents? What's wrong with a lot of small files? How to solve many small files? (big data)
- How much disk space does a new empty file take?
猜你喜欢
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
Detect certificate expiration script
甘特图对活动进行分组教程
【涂鸦物联网足迹】涂鸦云平台全景介绍
2020-08-14:数据任务的执行引擎用的哪些?
The isolation level of transaction and its problems
RFID fixed assets management system for fire equipment
大佬们如何在nginx镜像里面增加模块?
List to map (split the list according to the key, and the value of the same key is a list)
随机推荐
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
Stm32f030k6t6 compatible replacement smart mm32f031k6t6
2020-08-29:进程线程的区别,除了包含关系之外的一些区别,底层详细信息?
Summary of common SQL statements
打工人好物——磨炼钢铁意志就要这样高效的电脑
STM32F030C6T6兼容替换MM32SPIN05PF
Utility class functions (continuous update)
1万辆!理想汽车召回全部缺陷车:已发生事故97起,亏损将扩大
In 2020, how can wechat seal numbers be quickly lifted?
Win7 AppCrash (solution)
Stickinengine architecture 12 communication protocol
How much disk space does a new empty file take?
Stm32f030f4p6 compatible with smart micro mm32f031f4p6
[self taught unity2d legendary game development] map editor
Stm32f030c6t6 compatible to replace mm32spin05pf
Ora-02292: complete constraint violation (midbjdev2.sys_ C0020757) - subrecord found
[forward] how to view UserData in Lua
Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
ImageMagick - 添加水印
高速公路二维码定位报警系统