-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstream_test_car.py
More file actions
62 lines (48 loc) · 1.53 KB
/
stream_test_car.py
File metadata and controls
62 lines (48 loc) · 1.53 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from RealSense import *
import cv2 as cv
# import imutils
from numpysocket import NumpySocket
host_ip = '10.32.120.54' # change me
rs = None
rs = RealSense("/dev/video2", RS_VGA) # RS_VGA, RS_720P, or RS_1080P
writer = None
recording = False
frameIndex = 0
npSocket = None
npSocket = NumpySocket()
print("created socket")
npSocket.startClient(host_ip, 9999)
print("server started")
while True:
(frame_time, rgb, depth, accel, gyro) = rs.getData()
gray = cv.cvtColor(rgb, cv.COLOR_BGR2GRAY)
resize = cv.resize(gray,(640,480), interpolation = cv.INTER_AREA)
# print("gray shape",gray.shape)
npSocket.send2(resize)
print("sent:",frameIndex)
frameIndex += 1
# if writer is None and recording is True:
# # initialize our video writer
# writer = cv2.VideoWriter('Video.avi', cv2.VideoWriter_fourcc(*'MJPG'), 15, (rgb.shape[1], rgb.shape[0]), True)
# cv2.imshow("RGB", rgb)
# cv2.imshow("Depth", depth)
# if recording == True:
# # write the output frame to disk
# writer.write(rgb)
# key = cv2.waitKey(1) & 0xFF
# if key == ord("r"): # Start Recording
# recording = True
# if key == ord("s"): # Stop Recording
# recording = False
# if key == ord("i"): # Save image
# filename = "image" + str(frameIndex) + ".jpg"
# cv2.imwrite(filename, rgb)
# frameIndex += 1
# if key == ord("q"):
# break
if npSocket is not None:
npSocket.close()
if writer:
writer.release()
if rs is not None:
del rs