robokudo.utils.cv_bridge_workaround =================================== .. py:module:: robokudo.utils.cv_bridge_workaround .. autoapi-nested-parse:: A lightweight replacement for cv_bridge while NumPy 2 is in use. This class exists because the currently available ``cv_bridge`` binary can be compiled against NumPy 1.x and fails to import in environments that use NumPy 2. When ``cv_bridge`` wheels/packages become available that are compiled against NumPy 2, this module should be removed and users should switch back to ``cv_bridge.CvBridge``. Only a subset of the original interface is implemented here: * ``imgmsg_to_cv2`` * ``cv2_to_imgmsg`` The implementation intentionally focuses on encodings used by RoboKudo camera pipelines and type conversion helpers. Classes ------- .. autoapisummary:: robokudo.utils.cv_bridge_workaround.CVBridgeWorkaround Module Contents --------------- .. py:class:: CVBridgeWorkaround Subset replacement for ``cv_bridge.CvBridge``. The API is intentionally close to cv_bridge for drop-in usage in existing code paths. .. py:attribute:: _GENERIC_ENCODING_RE .. py:attribute:: _ENCODING_TO_DTYPE_CHANNELS .. py:method:: imgmsg_to_cv2(img_msg: sensor_msgs.msg.Image, desired_encoding: str = 'passthrough') -> numpy.typing.NDArray Convert ROS ``sensor_msgs/Image`` to a NumPy/OpenCV image. .. py:method:: cv2_to_imgmsg(cv_image: numpy.typing.NDArray, encoding: str = 'passthrough') -> sensor_msgs.msg.Image Convert a NumPy/OpenCV image to ROS ``sensor_msgs/Image``. .. py:method:: _encoding_to_dtype_channels(encoding: str) -> typing_extensions.Tuple[numpy.dtype, int] :classmethod: .. py:method:: _decode_image_message(msg: sensor_msgs.msg.Image) -> numpy.typing.NDArray :classmethod: .. py:method:: _infer_ros_encoding_from_cv_image(cv_image: numpy.typing.NDArray) -> str :classmethod: