启动浏览器后,扫描二维码,获取到的字符填充到搜索框,两段代码怎么融合?
建了一个浏览器,打开百度搜索,在搜索框中,要启动摄像头扫描二唯码获取字符,然后把字符填充到搜索框,这两段代码怎么融合起来呢。
启动浏览器
import sysfrom PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineView
app = QApplication(sys.argv)
browser = QWebEngineView()
browser.load(QUrl("http://www.baidu.com"))
browser.show()
app.exec_()
扫描二维码
import cv2from pyzbar import pyzbar
def scan_qrcode(qrcode):
data = pyzbar.decode(qrcode)
return data[0].data.decode('utf-8')
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
cv2.imshow('scan qrcode', frame)
# 解析二维码
text = None
try:
text = scan_qrcode(frame)
except Exception as e:
pass
if text:
print(text)
break
key = cv2.waitKey(10)
if key == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
以上是 启动浏览器后,扫描二维码,获取到的字符填充到搜索框,两段代码怎么融合? 的全部内容, 来源链接: utcz.com/p/938432.html