chore: changed video sending to work without cv2

This commit is contained in:
Storm
2026-01-27 17:58:06 +01:00
parent da97eb8a1a
commit 891ebf5e3f
2 changed files with 23 additions and 8 deletions

View File

@@ -61,7 +61,7 @@ class VideoConfig(object):
): ):
self.camera_index = get_config(camera_index, "VIDEO__CAMERA_INDEX", 0, int) self.camera_index = get_config(camera_index, "VIDEO__CAMERA_INDEX", 0, int)
self.resolution = get_config(resolution, "VIDEO__RESOLUTION", 2, int) self.resolution = get_config(resolution, "VIDEO__RESOLUTION", 2, int)
self.color_space = get_config(color_space, "VIDEO__COLOR_SPACE", 11, int) self.color_space = get_config(color_space, "VIDEO__COLOR_SPACE", 13, int)
self.fps = get_config(fps, "VIDEO__FPS", 15, int) self.fps = get_config(fps, "VIDEO__FPS", 15, int)
self.stream_name = get_config(stream_name, "VIDEO__STREAM_NAME", "Pepper Video") self.stream_name = get_config(stream_name, "VIDEO__STREAM_NAME", "Pepper Video")
self.image_buffer = get_config(image_buffer, "VIDEO__IMAGE_BUFFER", 6, int) self.image_buffer = get_config(image_buffer, "VIDEO__IMAGE_BUFFER", 6, int)

View File

@@ -2,6 +2,8 @@ import zmq
import threading import threading
import logging import logging
import numpy as np
from robot_interface.endpoints.socket_base import SocketBase from robot_interface.endpoints.socket_base import SocketBase
from robot_interface.state import state from robot_interface.state import state
from robot_interface.core.config import settings from robot_interface.core.config import settings
@@ -52,10 +54,23 @@ class VideoSender(SocketBase):
:param vid_stream_name: The name of a camera subscription on the video service object vid_service :param vid_stream_name: The name of a camera subscription on the video service object vid_service
:type vid_stream_name: str :type vid_stream_name: str
""" """
while not state.exit_event.is_set(): try:
try: while not state.exit_event.is_set():
img = vid_service.getImageRemote(vid_stream_name) try:
#Possibly limit images sent if queuing issues arise img = vid_service.getImageRemote(vid_stream_name)
self.socket.send(img[settings.video_config.image_buffer]) if img is not None:
except: raw_data = img[6]
logging.warn("Failed to retrieve video image from robot.") width = img[0]
height = img[1]
width_bytes = width.to_bytes(4, 'little')
height_bytes = height.to_bytes(4, 'little')
self.socket.send_multipart([width_bytes, height_bytes, raw_data])
except:
logging.warn("Failed to retrieve video image from robot.")
except KeyboardInterrupt:
logging.info("Video receiving loop interrupted by user.")
finally:
vid_service.unsubscribe(vid_stream_name)
logging.info("Unsubscribed from video stream.")