chore: changed video sending to work without cv2
This commit is contained in:
@@ -61,7 +61,7 @@ class VideoConfig(object):
|
||||
):
|
||||
self.camera_index = get_config(camera_index, "VIDEO__CAMERA_INDEX", 0, 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.stream_name = get_config(stream_name, "VIDEO__STREAM_NAME", "Pepper Video")
|
||||
self.image_buffer = get_config(image_buffer, "VIDEO__IMAGE_BUFFER", 6, int)
|
||||
|
||||
@@ -2,6 +2,8 @@ import zmq
|
||||
import threading
|
||||
import logging
|
||||
|
||||
import numpy as np
|
||||
|
||||
from robot_interface.endpoints.socket_base import SocketBase
|
||||
from robot_interface.state import state
|
||||
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
|
||||
:type vid_stream_name: str
|
||||
"""
|
||||
while not state.exit_event.is_set():
|
||||
try:
|
||||
img = vid_service.getImageRemote(vid_stream_name)
|
||||
#Possibly limit images sent if queuing issues arise
|
||||
self.socket.send(img[settings.video_config.image_buffer])
|
||||
except:
|
||||
logging.warn("Failed to retrieve video image from robot.")
|
||||
try:
|
||||
while not state.exit_event.is_set():
|
||||
try:
|
||||
img = vid_service.getImageRemote(vid_stream_name)
|
||||
if img is not None:
|
||||
raw_data = img[6]
|
||||
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.")
|
||||
Reference in New Issue
Block a user