Dynamsoft Barcode Reader教程:如何在Apple M1 Mac上通过Pip安装Python Barcode SDK 2021年1月17日 上午9:32 • 软件教程 有人可能对基于Intel的Python应用程序能否很好地运行感到好奇Apple M1 Mac。 Dynamsoft Barcode Reader SDK一款多功能的条码读取控件,只需要几行代码就可以将条码读取功能嵌入到Web或桌面应用程序。这可以节省数月的开发时间和成本。能支持多种图像文件格式以及从摄像机或扫描仪获取的DIB格式。使用Dynamsoft Barcode Reader SDK,你可以创建强大且实用的条形码扫描仪软件,以满足你的业务需求。 Dynamsoft Barcode Reader最新版 有人可能对基于Intel的Python应用程序能否很好地运行感到好奇Apple M1 Mac。我最近用Dynamsoft Python条形码SDK进行了测试,该SDK使用本机x86_64库和CPython。事实证明,使用pip该工具安装轮包并运行我的Python条码读取器应用程序没有任何问题。 安装Pip和Python条形码转盘软件包 当您打开终端应用程序并Python3第一次输入时,将弹出一个提示对话框,用于安装命令行开发人员工具。 curl https://bootstrap.pypa.io/get-pip.py -o get-pip.pypython3 get-pip.py 准备好点子之后,您可以尝试安装Dynamsoft Python条形码SDK: python3 -m pip install dbr 如果看到失败消息,请不要感到惊讶。 % file $(which python3)/usr/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]/usr/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64/usr/bin/python3 (for architecture arm64e): Mach-O 64-bit executable arm64e 如您所见,Python 3是通用应用程序,支持x86_64。因此,我们可以通过指定arch安装x86_64 wheel软件包: arch -x86_64 $(which python3) -m pip install dbr 恭喜你!您已经安装了Dynamsoft Python条形码SDK。从现在开始,您可以开始使用 络摄像头创建条形码扫描应用程序。 在Apple M1 Mac上构建基于 络摄像头的Python条形码阅读器 安装OpenCV-Python以捕获 络摄像头视频流: arch -x86_64 $(which python3) -m pip opencv-python 打开相机并实时显示视频流: import cv2 as cvcap = cv.VideoCapture(0)while True: _ret, frame = cap.read() if not _ret: break cv.imshow('BarcodeReader', frame) ch = cv.waitKey(1) # ESC if ch == 27: break 由于扫描条形码是一项占用大量CPU的任务,因此我们应该在Python进程而不是Python线程中运行它: from dbr import *from multiprocessing import Process, Queuedef process_barcode_frame(license, frameQueue, resultQueue): # Create Dynamsoft Barcode Reader reader = BarcodeReader() # Apply for a trial license: https://www.dynamsoft.com/customer/license/trialLicense reader.init_license(license) settings = reader.get_runtime_settings() settings.max_algorithm_thread_count = 1 reader.update_runtime_settings(settings) while True: results = None try: frame = frameQueue.get(False, 10) if type(frame) is str: break except: continue try: frameHeight, frameWidth, channel = frame.shape[:3] results = reader.decode_buffer_manually(np.array(frame).tobytes(), frameWidth, frameHeight, frame.strides[0], EnumImagePixelFormat.IPF_RGB_888) except BarcodeReaderError as error: print(error) try: resultQueue.put(results, False, 10) except: passbarcodeScanning = Process(target=process_barcode_frame, args=(license, frameQueue, resultQueue))barcodeScanning.start() 注意:您还需要有效的SDK许可证。 在主要过程中,创建两个队列以连续发送图像帧和接收条形码扫描结果: frameQueue = Queue(size)resultQueue = Queue(size)while True: _ret, frame = cap.read() if not _ret: break try: results = resultQueue.get(False, 10) except: pass cv.imshow('BarcodeReader', frame) # Append a frame to the frame queue try: frameQueue.put(frame.copy(), False, 10) except: pass ch = cv.waitKey(1) # ESC if ch == 27: break 现在,我们可以测试Python条形码程序: arch -x86_64 $(which python3) barcode_scanning.py license.txt 还有一件事,由于相机权限的限制,您可能无法运行该应用程序。除了终端应用程序,您还可以安装iTerm2来请求摄像头访问。 最后,我们可以在Apple M1 Mac上进行条形码扫描。 想要购买Dynamsoft Barcode Reader正版授权,或了解更多产品信息请点击【咨询在线客服】 标签: 声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢! 0 生成海 微信扫码分享 BI工具 Qlik 教程:客户位置 上一篇 2021年1月17日 流程图控件GoJS教程:内置GraphObject类各指数介绍(二) 下一篇 2021年1月17日 相关推荐 即用型UI组件Kendo UI,助力惠普(HP)缩短40%的应用开发时长! 2022年8月17日 Mindfusion教程:使用MindFusion JavaScript组件与WordPress Elementor插件 2019年3月16日 详解:FastReport 表生成器 2020年1月20日 快速入手光学字符识别控件Aspose.OCR!使用Java将图像转换为文本 2020年6月27日 图形处理控件Aspose.PSD 入门教程(1):在 C# 中以编程方式向图像添加签名 2022年1月19日 前端优化:九个技巧,提高Web性能 2017年1月6日 发表回复 请登录后评论... 登录后才能评论 提交