-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcamera_client.py
More file actions
37 lines (29 loc) · 968 Bytes
/
camera_client.py
File metadata and controls
37 lines (29 loc) · 968 Bytes
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
36
37
#must be run on the RPi or client
import io
import socket
import struct
import time
import picamera
import sys
def main():
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((sys.argv[1], int(sys.argv[2])))
connection = client_socket.makefile('wb')
try:
with picamera.PiCamera() as camera:
camera.resolution = (1080, 1980)
print("starting Camera...........")
time.sleep(2)
stream = io.BytesIO()
for foo in camera.capture_continuous(stream, 'jpeg'):
connection.write(struct.pack('<L', stream.tell()))
connection.flush()
stream.seek(0)
connection.write(stream.read())
stream.seek(0)
stream.truncate()
finally:
connection.close()
client_socket.close()
if __name__ == "__main__":
main()