Skip to content

Commit

Permalink
Fix instance problem ros image
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinSchmid7 committed Aug 16, 2023
1 parent 4651cb9 commit fcf89e0
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit fcf89e0

Please sign in to comment.