|
|
|
|
|
|
|
|
# Connect a client socket to my_server:8000 (change my_server to the |
|
|
# Connect a client socket to my_server:8000 (change my_server to the |
|
|
# hostname of your server) |
|
|
# hostname of your server) |
|
|
client_socket = socket.socket() |
|
|
client_socket = socket.socket() |
|
|
client_socket.connect(('my_server', 8000)) |
|
|
|
|
|
|
|
|
client_socket.connect(('192.168.1.107', 8000)) |
|
|
|
|
|
|
|
|
# Make a file-like object out of the connection |
|
|
# Make a file-like object out of the connection |
|
|
connection = client_socket.makefile('wb') |
|
|
connection = client_socket.makefile('wb') |
|
|
|
|
|
|
|
|
while True: |
|
|
while True: |
|
|
ret, frame = cap.read() |
|
|
ret, frame = cap.read() |
|
|
|
|
|
|
|
|
if frame == None: |
|
|
|
|
|
|
|
|
if frame is None: |
|
|
break |
|
|
break |
|
|
|
|
|
|
|
|
image = cv2.imencode('.jpg', frame) |
|
|
|
|
|
|
|
|
print(type(frame)) |
|
|
|
|
|
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) |
|
|
|
|
|
print(type(gray)) |
|
|
|
|
|
_, image = cv2.imencode('.jpg', gray) |
|
|
|
|
|
print(type(image)) |
|
|
stream = image.tobytes() |
|
|
stream = image.tobytes() |
|
|
|
|
|
print(type(stream)) |
|
|
|
|
|
|
|
|
# Write the length of the capture to the stream and flush to |
|
|
# Write the length of the capture to the stream and flush to |
|
|
# ensure it actually gets sent |
|
|
# ensure it actually gets sent |