在Raspberry Pi上集成/连接对象检测(网络摄像头)4
我正在尝试使用Python语言进行对象检测程序,并希望将其连接到Raspberry Pi的GPIO。
for code in decode(frame):
decoded_data = code.data.decode("utf-8")
rect_pts = code.rect
print("\nID:", code.data.decode("utf-8"))
if decoded_data in reg_qr:
infoOut = 'Authorized'
bbColor = (0,255,0)
else:
infoOut = 'Un-Authorized'
bbColor = (0,0,255)
pts = np.array([code.polygon], np.int32)
cv2.polylines(frame, [pts], True, bbColor, 3)
cv2.putText(frame, infoOut, (rect_pts[0], rect_pts[1]), cv2.FONT_HERSHEY_SIMPLEX, 1, bbColor,3)
那就是Python代码段。 根据算法,它运行良好。但是,当我想使用此语法驾驶伺服器时,我
if decoded_data in reg_qr:
angle = 90
servo1.ChangeDutyCycle(2+(angle/18))
servo1.ChangeDutyCycle(0)
time.sleep(2)
if distance <= 5.01:
angle = 90
servo1.ChangeDutyCycle(2+(angle/18))
time.sleep(2)
servo1.ChangeDutyCycle(0)
认为这与用超声波传感器的输入驾驶伺服器相同。原来我错了。有人知道解决方案吗?
I'm trying an object detection program using Python language, and want to connect it to the Raspberry Pi's GPIO.
for code in decode(frame):
decoded_data = code.data.decode("utf-8")
rect_pts = code.rect
print("\nID:", code.data.decode("utf-8"))
if decoded_data in reg_qr:
infoOut = 'Authorized'
bbColor = (0,255,0)
else:
infoOut = 'Un-Authorized'
bbColor = (0,0,255)
pts = np.array([code.polygon], np.int32)
cv2.polylines(frame, [pts], True, bbColor, 3)
cv2.putText(frame, infoOut, (rect_pts[0], rect_pts[1]), cv2.FONT_HERSHEY_SIMPLEX, 1, bbColor,3)
That is the Python code snippet.
It runs fine, according to the algorithm. But when I want to drive the servo with this syntax, I can't
if decoded_data in reg_qr:
angle = 90
servo1.ChangeDutyCycle(2+(angle/18))
servo1.ChangeDutyCycle(0)
time.sleep(2)
if distance <= 5.01:
angle = 90
servo1.ChangeDutyCycle(2+(angle/18))
time.sleep(2)
servo1.ChangeDutyCycle(0)
I think it would be the same as driving the servo with the input from the ultrasonic sensor. Turns out I was wrong. Anyone know the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论