Skip to content

Commit ee24f09

Browse files
author
sappel
committedFeb 28, 2021
Add video to readme for networks
1 parent ed2e9be commit ee24f09

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed
 

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ On your other device run VLC and connect to `rtsp:://IP.OF.RAS.PI::8554`
5252

5353
### Ultrasonics
5454

55+
### Network
56+
https://www.youtube.com/watch?v=bWwZF_zVf00
57+
5558
# Helpful links
5659
* https://www.hackster.io/bestd25/pi-car-016e66
5760
* https://www.pyimagesearch.com/2015/03/30/accessing-the-raspberry-pi-camera-with-opencv-and-python/

‎network/client.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
client_socket = socket.socket()
99

1010
client_socket.connect(ip_address, port)
11-
11+
# Write bytes
1212
connection = client_socket.makefile('wb')
1313
try:
1414
camera = picamera.Picamera()
1515
camera.vflip = True
16-
camera.resolution = (640, 480)
16+
camera.resolution = (320, 240)
1717
camera.start_preview()
1818
time.sleep(2)
1919

@@ -27,7 +27,13 @@
2727
stream.seek(0)
2828
connection.write(stream.read())
2929

30+
# Run the stream for 30 seconds
3031
if time.time() - start > 30:
3132
break
33+
stream.seek(0)
34+
stream.truncate()
35+
36+
connection.write(struct.pack('<L', 0))
3237
finally:
33-
break
38+
connection.close()
39+
client_socket.close()

‎network/server.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
server_socket.bind((ip_address, port))
1010
server_socket.listen(0)
1111

12+
# Read bytes
1213
connection = server_socket.accept()[0].makefile('rb')
1314

1415
try:
@@ -37,4 +38,5 @@
3738

3839

3940
finally:
40-
pass
41+
connection.close()
42+
server_socket.close()

0 commit comments

Comments
 (0)
Please sign in to comment.