How can i send cv2.frames to a browser
opencv, python, sockets
Solution
I had the same problem, in my case I was reading from video file but it should work. Use cv2.imencode() method. See the following code
def send_a_frame():
capture = cv2.VideoCapture(0)
frame = capture.read()[1]
cnt = cv2.imencode('.png',frame)[1]
b64 = base64.encodestring(cnt)
html = "<html><img src='data:image/png;base64,"+b64 +"'></html"
send(html)
Problem
I am trying to send a webcam image to browser using Python. Now, I send it using the following code: ``` 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) ``` How can I save an image and reopen an image and convert to base64 with a single statement?