我正在尝试使用 Python 将网络摄像头图像发送到浏览器。现在,我使用以下代码发送它:
def send_a_frame():
capture = cv2.VideoCapture(0)
frame = capture.read()[1]
cv2.imwrite("im1.png",frame)
cnt = open("im1.png","rb").read()
b64 = base64.encodestring(cnt)
html = "<html><img src='data:image/png;base64,"+base64 +"'></html"
send(html)
如何使用单个语句保存图像并重新打开图像并转换为 base64?