-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
34 lines (30 loc) · 986 Bytes
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# USAGE
# python client.py --server-ip SERVER_IP
# import the necessary packages
from imutils.video import VideoStream
import imagezmq
import argparse
import socket
import time
import cv2
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-s", "--server-ip", required=True,
help="ip address of the server to which the client will connect")
args = vars(ap.parse_args())
# initialize the ImageSender object with the socket address of the
# server
sender = imagezmq.ImageSender(connect_to="tcp://{}:5050".format(args["server_ip"]))
if(sender):
print("Connected")
# get the host name, initialize the video stream, and allow the
# camera sensor to warmup
# rpiName = socket.gethostname()
# vs = VideoStream(usePiCamera=True).start()
vs = VideoStream(src=0).start()
time.sleep(2.0)
print("Reached here")
while True:
# read the frame from the camera and send it to the server
frame = vs.read()
sender.send_image("Hey there", frame)