没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:黄竹雯|2019-06-10 14:20:52.040|阅读 615 次
概述:
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
如果你想快速创建一个步行机器人,你可以使用Lego Boost(机器人编程入门神器)。在这篇文章中,小编将分享如何使用Webcam(网络摄像头),Lego Boost和Dynamsoft Barcode Reader SDK来制作用于扫描条形码的机器人。本文中使用的编程语言是Python。
要构建机器人,请安装Boost app并按照相关教程进行操作。
下载Dynamsoft Barcode Reader for Linux。解压缩包后,将libDynamsoftBarcodeReader.so 复制 到 / usr / lib。
获取Dynamsoft Barcode SDK的30天免费试用许可证。
获取 Dynamsoft Python条形码模块的,并按照步骤进行构建和安装。
安装一个蓝牙后端:
pip install pygatt pip install gatt pip install gattlib pip install bluepy
安装pylgbst与Lego Boost Move Hub进行交互:
pip install //github.com/undera/pylgbst/archive/1.0.tar.gz
安装OpenCV Python:
pip install opencv-python # or pip3 install opencv-python
使用OpenCV创建摄像机视图窗口:
vc = cv2.VideoCapture(0) vc.set(3, 640) #set width vc.set(4, 480) #set height if vc.isOpened(): # try to get the first frame rval, frame = vc.read() else: return windowName = "Robot View" try: while True: rval, frame = vc.read() cv2.imshow(windowName, frame)
由于GIL(Python Global Interpreter Lock)全局锁,我们需要在另一个进程而不是线程中运行蓝牙连接代码和条形码解码算法。所有数据(包括关键事件,网络摄像头帧和条形码结果)都通过队列传输:
num = Value('i', 1) result_queue = Queue(1) key_queue = Queue(1) frame_queue = Queue(1) cond = Condition() dbr_proc = Process(target=dbr_run, args=( frame_queue, key_queue, cond, num, result_queue)) dbr_proc.start()
以下是关键定义:
控制乐高升力机器人的代码非常简单。小编用Gatt Backend:
conn GattConnection() try: conn.connect() hub = MoveHub(conn) print('Robot connected') speed = 0.5 if key == ord('a'): # left hub.motor_AB.angled(90, speed * -1, speed) elif key == ord('d'): # right hub.motor_AB.angled(90, speed, speed * -1) elif key == ord('w'): # up hub.motor_AB.start_speed(speed) elif key == ord('s'): # down hub.motor_AB.start_speed(speed * -1) elif key == ord('p'): hub.motor_AB.stop() finally: conn.disconnect()
阅读QR码并将结果放入队列:
conn GattConnection() dbr.initLicense('LICENSE-KEY') if key == ord('c'): inputframe = frame_queue.get() results = dbr.decodeBuffer(inputframe, 0x4000000) if (len(results) > 0): for result in results: print("Type: " + result[0]) print("Value: " + result[1] + "\n") result_queue.put(Result(inputframe, results))
使用OpenCV绘制条形码位置和解码文本结果:
ret = result_queue.get_nowait() results = ret.results image = ret.image thickness = 2 color = (0,255,0) for result in results: print("barcode format: " + result[0]) print("barcode value: " + result[1]) x1 = result[2] y1 = result[3] x2 = result[4] y2 = result[5] x3 = result[6] y3 = result[7] x4 = result[8] y4 = result[9] cv2.line(image, (x1, y1), (x2, y2), color, thickness) cv2.line(image, (x2, y2), (x3, y3), color, thickness) cv2.line(image, (x3, y3), (x4, y4), color, thickness) cv2.line(image, (x4, y4), (x1, y1), color, thickness) cv2.putText(image, result[1], (min([x1, x2, x3, x4]), min([y1, y2, y3, y4])), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,0,255), thickness) cv2.imshow("Localization", image)
运行app
python3 app.py
购买Dynamsoft Barcode Reader正版授权的朋友可以点击""哦~~~
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@wqylolg.cn
在 Excel 工作表中,原始数据通常显示为缺乏直观性的普通数字。通过设置数字格式,可以将这些数字转换成更容易理解的形式。本文将介绍如何使用 Spire.XLS for .NET 通过 C# 设置 Excel 单元格中的数字格式 。
本文将演示如何使用 Spire.XLS for .NET 通过 C# 合并或取消合并 Excel 中的单元格。
Excel 文档的常规打印操作十分简单。然而,一旦涉及特殊打印需求,情况就会变得比较麻烦。文将介绍如何使用 Spire.XLS for .NET 在 C# 中通过页面设置对 Excel 打印选项进行设置,以及如何将 Excel 文档发送到打印机。
在本指南中,我们将向您展示如何免费在线旋转 PDF,并探索 Python、Java 和 C# 中的基于代码的方法。最后,您将了解最适合您需求的方法。
Dynamsoft Barcode Reader SDK是一款多功能的条码读取控件。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@wqylolg.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢