-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
35 lines (30 loc) · 989 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
35
# USAGE
# python client.py --server-ip SERVER_IP
# import the necessary packages
from getmac import get_mac_address
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://{}:5555".format(
args["server_ip"]))
# get the host name, initialize the video stream, and allow the
# camera sensor to warmup
rpiName = get_mac_address()
#vs = VideoStream(usePiCamera=True).start()
vs = VideoStream(src=0).start()
#cap = cv2.VideoCapture(0)
time.sleep(2.0)
while True:
# read the frame from the camera and send it to the server
frame = vs.read()
sender.send_image(rpiName, frame)