diff --git a/raspberryPi/stream_client.py b/raspberryPi/stream_client.py new file mode 100644 index 0000000..f0ce7a7 --- /dev/null +++ b/raspberryPi/stream_client.py @@ -0,0 +1,41 @@ +""" +Reference: +PiCamera documentation +https://picamera.readthedocs.org/en/release-1.10/recipes2.html + +""" + +import io +import socket +import struct +import time +import picamera + + +# create socket and bind host +client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +client_socket.connect(('192.168.1.100', 8000)) +connection = client_socket.makefile('wb') + +try: + with picamera.PiCamera() as camera: + camera.resolution = (320, 240) # pi camera resolution + camera.framerate = 10 # 10 frames/sec + time.sleep(2) # give 2 secs for camera to initilize + start = time.time() + stream = io.BytesIO() + + # send jpeg format video stream + for foo in camera.capture_continuous(stream, 'jpeg', use_video_port = True): + connection.write(struct.pack(' 600: + break + stream.seek(0) + stream.truncate() + connection.write(struct.pack('