1234567891011121314151617181920212223 |
- from imutils.video import VideoStream
- import imagezmq
- import argparse
- import socket
- import time
-
- # 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"]))
-
- rpi_name = socket.gethostname() # send RPi hostname with each image
- picam = VideoStream(usePiCamera=True).start()
- time.sleep(2.0) # allow camera sensor to warm up
- while True: # send images as stream until Ctrl-C
- image = picam.read()
- sender.send_image(rpi_name, image)
|