|
12 | 12 | from TeleVision import OpenTeleVision
|
13 | 13 | import pyzed.sl as sl
|
14 | 14 | from dynamixel.active_cam import DynamixelAgent
|
15 |
| -from multiprocessing import Array, Process, Queue, shared_memory |
| 15 | +from multiprocessing import Array, Process, shared_memory, Queue, Manager, Event, Semaphore |
16 | 16 |
|
17 | 17 | resolution = (720, 1280)
|
18 |
| -crop_size_w = 340 # (resolution[1] - resolution[0]) // 2 |
19 |
| -crop_size_h = 270 |
20 |
| -resolution_cropped = (resolution[0] - crop_size_h, resolution[1] - 2 * crop_size_w) # 450 * 600 |
| 18 | +crop_size_w = 1 |
| 19 | +crop_size_h = 0 |
| 20 | +resolution_cropped = (resolution[0] - crop_size_h, resolution[1] - 2 * crop_size_w) |
21 | 21 |
|
22 | 22 | agent = DynamixelAgent(port="/dev/serial/by-id/usb-FTDI_USB__-__Serial_Converter_FT8IT033-if00-port0")
|
23 | 23 | agent._robot.set_torque_mode(True)
|
|
42 | 42 | image_right = sl.Mat()
|
43 | 43 | runtime_parameters = sl.RuntimeParameters()
|
44 | 44 |
|
45 |
| -img_shape = (2 * resolution_cropped[0], resolution_cropped[1], 3) # 900 * 600 |
46 |
| -img_height, img_width = resolution_cropped[:2] # 450 * 600 |
| 45 | +img_shape = (resolution_cropped[0], 2 * resolution_cropped[1], 3) |
| 46 | +img_height, img_width = resolution_cropped[:2] |
47 | 47 | shm = shared_memory.SharedMemory(create=True, size=np.prod(img_shape) * np.uint8().itemsize)
|
48 |
| -shm_name = shm.name |
49 | 48 | img_array = np.ndarray((img_shape[0], img_shape[1], 3), dtype=np.uint8, buffer=shm.buf)
|
50 |
| - |
51 |
| -tv = OpenTeleVision(resolution_cropped, shm_name) |
| 49 | +image_queue = Queue() |
| 50 | +toggle_streaming = Event() |
| 51 | +tv = OpenTeleVision(resolution_cropped, shm.name, image_queue, toggle_streaming) |
52 | 52 |
|
53 | 53 | while True:
|
54 | 54 | start = time.time()
|
|
75 | 75 | # print("Image resolution: {0} x {1} || Image timestamp: {2}\n".format(image.get_width(), image.get_height(),
|
76 | 76 | # timestamp.get_milliseconds()))
|
77 | 77 |
|
78 |
| - bgr = np.vstack((image_left.numpy()[crop_size_h:, crop_size_w:-crop_size_w], |
| 78 | + bgr = np.hstack((image_left.numpy()[crop_size_h:, crop_size_w:-crop_size_w], |
79 | 79 | image_right.numpy()[crop_size_h:, crop_size_w:-crop_size_w]))
|
80 | 80 | rgb = cv2.cvtColor(bgr, cv2.COLOR_BGRA2RGB)
|
81 |
| - # print(rgb.shape) |
82 | 81 |
|
83 | 82 | np.copyto(img_array, rgb)
|
84 | 83 |
|
|
0 commit comments