I'm trying to stream my webcam from my server to the client. I understand sockets but I don't know what to send... Here is my code for the webcam:
import Tkinter as tk
import cv2
from PIL import Image, ImageTk
import numpy as np
import time
cap = cv2.VideoCapture(0)
cap.set(3,920)
cap.set(4,840)
root = tk.Tk()
root.bind('<Escape>', lambda e: root.quit())
lmain = tk.Label(root)
lmain.pack()
def show_frame():
_, frame = cap.read()
frame = cv2.flip(frame, 1)
cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
img = Image.fromarray(cv2image)
imgtk = ImageTk.PhotoImage(image=img)
lmain.imgtk = imgtk
lmain.configure(image=imgtk)
lmain.after(10, show_frame)
time.sleep(2)
show_frame()
root.mainloop()
I'm guessing it would be something like this:
f = open('textFile.txt','rb')
l = f.read(1024)
while (l):
c.send(l)
l = f.read(1024)
if l == '':
break
f.close()
c.close()
The above is for a file, I know, but I Can't figure out what "l" should be to send the webcam data to the client. I'm stumped.