Skip to content

Commit 9c4529b

Browse files
committed
active_cam bug fix
1 parent 8d98627 commit 9c4529b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Suppose the local ip address of the ubuntu machine is `192.168.8.102`.
6868
```
6969
mkcert -install && mkcert -cert-file cert.pem -key-file key.pem 192.168.8.102 localhost 127.0.0.1
7070
```
71+
ps. place the generated `cert.pem` and `key.pem` files in `teleop`.
7172

7273
4. open firewall on server
7374
```

teleop/teleop_active_cam.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
from TeleVision import OpenTeleVision
1313
import pyzed.sl as sl
1414
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
1616

1717
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)
2121

2222
agent = DynamixelAgent(port="/dev/serial/by-id/usb-FTDI_USB__-__Serial_Converter_FT8IT033-if00-port0")
2323
agent._robot.set_torque_mode(True)
@@ -42,13 +42,13 @@
4242
image_right = sl.Mat()
4343
runtime_parameters = sl.RuntimeParameters()
4444

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]
4747
shm = shared_memory.SharedMemory(create=True, size=np.prod(img_shape) * np.uint8().itemsize)
48-
shm_name = shm.name
4948
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)
5252

5353
while True:
5454
start = time.time()
@@ -75,10 +75,9 @@
7575
# print("Image resolution: {0} x {1} || Image timestamp: {2}\n".format(image.get_width(), image.get_height(),
7676
# timestamp.get_milliseconds()))
7777

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],
7979
image_right.numpy()[crop_size_h:, crop_size_w:-crop_size_w]))
8080
rgb = cv2.cvtColor(bgr, cv2.COLOR_BGRA2RGB)
81-
# print(rgb.shape)
8281

8382
np.copyto(img_array, rgb)
8483

0 commit comments

Comments
 (0)