-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement image transfer #5
Comments
Created the Streamer class for the TCP image transfer.
The Streamer class was created. The class was tested with the server and client scripts: # server.py
import socket
import numpy as np
import cv2
host = "localhost"
port = 5000
server_address = (host, port)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(server_address)
print('starting up on %s:%s' % server_address)
while True:
data, address = sock.recvfrom(65535)
nparr = np.frombuffer(data, np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
cv2.imshow('Server feed',img)
# print(data)
if cv2.waitKey(1) & 0xFF == ord('q'):
break # client.py
import socket
from modules.Streamer import Streamer
streamer = Streamer("localhost", 5000, 0)
streamer.send_to_server() The class uses TCP to send the image data to the server. While testing, a problem was discovered. Size of a image that is sent over the TCP tends to exceed the maximal size of 65535 bytes. The problem can be avioded by slightly changing the Recorder class to output JPEGs with lower quality. For example, in the success, image = self.video.read()
encode_param = [int(cv2.IMWRITE_JPEG_QUALITY), 75]
ret, jpeg = cv2.imencode('.jpg', image, encode_param) |
Added the destructor method to the Streamer class which closes the opened socket.
Implement a class that enables sending images from the client (Raspberry PI) to the server (GCP VM Instance).
Class name: "Streamer".
Store the class source code inside the "modules" folder.
The text was updated successfully, but these errors were encountered: