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

default to encoding in the image message #921

Merged
merged 1 commit into from
Jan 31, 2024
Merged
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
10 changes: 7 additions & 3 deletions image_view/scripts/extract_images_sync
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ Typical command-line usage:
bridge = cv_bridge.CvBridge()
for i, imgmsg in enumerate(imgmsgs):
img = bridge.imgmsg_to_cv2(imgmsg)
channels = img.shape[2] if img.ndim == 3 else 1
encoding_in = bridge.dtype_with_channels_to_cvtype2(
img.dtype, channels)
# Default to the encoding in the image message
encoding_in = imgmsg.encoding
if not encoding_in:
# Encoding is not specified, try to automatically determine
channels = img.shape[2] if img.ndim == 3 else 1
encoding_in = bridge.dtype_with_channels_to_cvtype2(
img.dtype, channels)
img = cv_bridge.cvtColorForDisplay(
img, encoding_in=encoding_in, encoding_out='',
do_dynamic_scaling=self.do_dynamic_scaling)
Expand Down
Loading