Dynamsoft Barcode Reader使用教程:如何使用LabelImg注释条形码对象以进行机器学习

Dynamsoft Barcode Reader SDK一款多功能的条码读取控件,只需要几行代码就可以将条码读取功能嵌入到Web或桌面应用程序。这可以节省数月的开发时间和成本。能支持多种图像文件格式以及从摄像机或扫描仪获取的DIB格式。使用Dynamsoft Barcode Reader SDK,你可以创建强大且实用的条形码扫描仪软件,以满足你的业务需求。

Dynamsoft Barcode Reader最新版

图片下载

首先,我们需要图像。我们如何获得一堆具有相同分类的图像/span>
有一个方便的Python库google_images_download。

pip install google_images_download

当我运行库时,我发现它通常无法正常工作。它总是无法下载任何图像。该问题已在https://github.com/hardikvasa/google-images-download/issues/331上提及。幸运的是,有人提供了可行的解决方法。我们可以使用已修复问题的分支存储库:

git clone https://github.com/Joeclinton1/google-images-download.gitcd google-images-download && python setup.py install

根据在线文档,我们可以编写一个简单的Python脚本来下载图像,如下所示:

from google_images_download import google_images_download import argparseap = argparse.ArgumentParser()ap.add_argument("-k", "--keywords", required=True,    help="The keywords/key phrases you want to search for.")ap.add_argument("-l", "--limit", required=True,    help="The number of images that you want to download.")args = vars(ap.parse_args())response = google_images_download.googleimagesdownload()arguments = {"keywords":args["keywords"],"limit":args["limit"],"print_urls":True} paths = response.download(arguments)print(paths)

将Python脚本保存到google-image-downloader.py。

让我们从Google下载10张PDF417图像:

python3 google-image-downloader.py -k pdf417 -l 10

条形码对象注释

条形码图像准备就绪后,我们就可以开始为条形码加标签了。

第一步是获取LabelImg存储库的源代码:

git clone https://github.com/tzutalin/labelImg.git

使用LabelImg,我们可以通过眼睛标记大多数对象。但是,您可能不知道所有条形码符 。为了精确快速地命名条形码对象,我们可以使用Dynamsoft Barcode Reader作为辅助工具:

pip install dbr

初始化Dynamsoft条码阅读器非常简单:

from dbr import *reader = BarcodeReader()

转到labelImg.py中的函数newShape(self)。完成为对象绘制边界框后,将触发该功能。

下一步是从当前形状获取坐标,该坐标存储为画布中形状数组的最后一个元素:

shape = self.canvas.shapes[-1]

形状有四个点。为了提取坐标值并为Dynamsoft Barcode Reader设置区域值,我们使用左上角和右下角:

reader.reset_runtime_settings()shape = self.canvas.shapes[-1]points = shape.pointssettings = reader.get_runtime_settings()settings.region_bottom  = round(points[2].y())settings.region_left    = round(points[0].x())settings.region_right   = round(points[2].x())settings.region_top     = round(points[0].y())reader.update_runtime_settings(settings)

之后,我们可以通过调用Python条形码解码API来获取区域内的条形码信息:

try:            text_results = reader.decode_file(self.filePath)            if text_results != None:                for text_result in text_results:                    print("Barcode Format :")                    print(text_result.barcode_format_string)                    self.prevLabelText = text_result.barcode_format_string                    print("Barcode Text :")                    print(text_result.barcode_text)                    print("Localization Points : ")                    print(text_result.localization_result.localization_points)                    print("-------------")        except BarcodeReaderError as bre:            print(bre)

保存labelImg.py文件并运行程序:

python3 labelImg.py

当您为条形码对象创建一个矩形框时,它将自动用相应的条形码类型填充标签对话框。

labelimg 3¨é

想要购买Dynamsoft Barcode Reader正版授权,或了解更多产品信息请点击【咨询在线客服】

Dynamsoft Barcode Reader使用教程:如何使用LabelImg注释条形码对象以进行机器学习

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年10月23日
下一篇 2020年10月23日

相关推荐

发表回复

登录后才能评论