-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created the Streamer class for the TCP image transfer.
- Loading branch information
1 parent
d6d3dc4
commit 2899e9f
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import socket | ||
from modules.Recorder import Recorder | ||
|
||
class Streamer(object): | ||
''' | ||
Sets the socket and the server address and get the camera from the Recorder class.2 | ||
Arguments: | ||
host(str) IP address of a server to stream to | ||
port(str) port of a server to stream to | ||
''' | ||
def __init__(self, host, port, camera_num): | ||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
self.server_address = (host, port) | ||
self.camera = Recorder(camera_num) | ||
|
||
''' | ||
Gets a frame from camera and sends it to the server via UDP. | ||
''' | ||
def send_to_server(self): | ||
while True: | ||
frame = self.camera.get_frame() | ||
length = len(frame) | ||
# print("Len: " + str(length)) | ||
if(length < 65536): | ||
self.sock.sendto(frame, self.server_address) |