zmq version for video file

This commit is contained in:
Lennart Heimbs 2019-08-04 17:31:58 +02:00
parent bac291dc7b
commit 41ef2c4cb6
2 changed files with 38 additions and 6 deletions

View File

@ -1,11 +1,20 @@
# run this program on each RPi to send a labelled image stream
import socket
import time
from imutils.video import VideoStream from imutils.video import VideoStream
import imagezmq import imagezmq
import argparse
sender = imagezmq.ImageSender(connect_to='tcp://jeff-macbook:5555') 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 rpi_name = socket.gethostname() # send RPi hostname with each image
picam = VideoStream(usePiCamera=True).start() picam = VideoStream(usePiCamera=True).start()
time.sleep(2.0) # allow camera sensor to warm up time.sleep(2.0) # allow camera sensor to warm up

View File

@ -0,0 +1,23 @@
from imutils.video import FileVideoStream
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
video_file = FileVideoStream("../run.mp4").start()
time.sleep(2.0) # allow camera sensor to warm up
while video_file.more():
image = video_file.read()
sender.send_image(rpi_name, image)