diff --git a/wild_visual_navigation_ros/src/wild_visual_navigation_ros/ros_converter.py b/wild_visual_navigation_ros/src/wild_visual_navigation_ros/ros_converter.py index a8dff961..9aa50768 100644 --- a/wild_visual_navigation_ros/src/wild_visual_navigation_ros/ros_converter.py +++ b/wild_visual_navigation_ros/src/wild_visual_navigation_ros/ros_converter.py @@ -106,15 +106,14 @@ def ros_tf_to_torch(tf_pose, device="cpu"): def ros_image_to_torch(ros_img, desired_encoding="rgb8", device="cpu"): - if isinstance(ros_img, Image): + if type(ros_img).__name__ is "_sensor_msgs__Image": np_image = CV_BRIDGE.imgmsg_to_cv2(ros_img, desired_encoding=desired_encoding) - elif isinstance(ros_img, CompressedImage): + elif type(ros_img).__name__ is "_sensor_msgs__CompressedImage": np_arr = np.fromstring(ros_img.data, np.uint8) np_image = cv2.imdecode(np_arr, cv2.IMREAD_COLOR) if "bgr" in ros_img.format: np_image = cv2.cvtColor(np_image, cv2.COLOR_BGR2RGB) - return TO_TENSOR(np_image).to(device)