Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix instance detection ros image #272

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,26 @@ 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):
# Use for replaying bag with BagTfTransformer package
if type(ros_img).__name__ is "_sensor_msgs__Image":
np_image = CV_BRIDGE.imgmsg_to_cv2(ros_img, desired_encoding=desired_encoding)

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)

# Used for replaying with rosbags via terminal
elif isinstance(ros_img, Image):
np_image = CV_BRIDGE.imgmsg_to_cv2(ros_img, desired_encoding=desired_encoding)

elif isinstance(ros_img, 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
Loading