当前位置:网站首页>条形码识别性能低,如何优化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
边栏推荐
- September 3, 2020: naked writing algorithm: loop matrix traversal.
- Interviewer: how about shardingsphere
- A concise tutorial for Nacos, ribbon and feign
- #JVM 类加载机制
- Google browser realizes video playback acceleration function
- Exclusive interview of guests at | 2020 PostgreSQL Asia Conference: Wang Tao
- Experiment one
- win7 APPCRASH(解决方法)(转)
- Win7 AppCrash (solution)
- 预留电池接口,内置充放电电路及电量计,迅为助力轻松搞定手持应用
猜你喜欢
细数软件工程----各阶段必不可少的那些图
To solve the problem that the data interface is not updated after WPF binding set
Unexpected element.. required element
Utility class functions (continuous update)
September 9, 2020: naked writing algorithm: two threads print numbers 1-100 in turn.
Application of UHF RFID medical blood management system
“非洲用户的付费意愿并不低”——专访四达时代研发总监张亮
JS string - string string object method
心理咨询app开发所具备的优点与功能
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
随机推荐
大佬们如何在nginx镜像里面增加模块?
轻量型 GPU 应用首选 京东智联云推出 NVIDIA vGPU 实例
JS string - string string object method
#JVM 类加载机制
南京标识标牌设计制作,导视VI系统设计
What grammar is it? ]
VARCHART XGantt入门教程
JVM class loading mechanism
WebAPI接口设计:SwaggerUI文档 / 统一响应格式 / 统一异常处理 / 统一权限验证
The advantages and functions of psychological counseling app
Characteristics of magnetic memory chip STT-MRAM
Points to be considered when deleting mapping field of index in ES
The role of theme music in games
2020-08-19: what mechanism does TCP ensure reliability?
Road to simple HTML + JS to achieve the most simple game Tetris
To solve the problem that the data interface is not updated after WPF binding set
Unexpected element.. required element
Application insights application insights use application maps to build request link views
甘特图对活动进行分组教程
How much disk space does a file of 1 byte actually occupy