image_transport::SubscriberFilter decodes 16bit png to 8bit

Open
#90 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Start by tracing the image_transport::SubscriberFilter compressed-image decoding path and compare it with the IMREAD_UNCHANGED behavior referenced in the issue. Use the provided single-channel uint16 PNG reproduction and confirm that the synchronizer callback preserves the mono16 encoding.

Written by the indexing model from the issue text.

Description

I am publishing a png compressed depth image in python via:

msg_dimg_compr = self.cvbridge.cv2_to_compressed_imgmsg(dimg, dst_format="png")

to /camera/depth/image_rect_raw/compressed, where dimg is a single channel 16bit (np.uint16) image.
This seems to work fine since manually decoding the raw data (e.g. as in PR https://github.com/ros-perception/vision_opencv/pull/228) gives me the same 16bit image.

But using a image_transport::SubscriberFilter for synchronisation in C++ like:

image_transport::SubscriberFilter sub_image_depth;
sub_image_depth.subscribe(...);
sync_rgbd = message_filters::Synchronizer<ApproximateTime...>(sub_image_depth, ...);
sync_rgbd.registerCallback(sync_cb);

gives me a mono8 instead of a mono16 image in the callback:

void sync_cb(sensor_msgs::ImageConstPtr depth_img_msg, ....) {
    depth_img_msg->encoding; // <- this is "mono8" instead of "mono16"
}

This might be related to https://github.com/ros-perception/image_common/issues/77 and https://github.com/ros-perception/vision_opencv/issues/206. I.e. images need to be decoded using the IMREAD_UNCHANGED flag.

Dominant language
C++
Stars
154
Forks
258
Avg merge
2d 1h
Merged PRs (30d)
3

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ros-perception/image_common

All issues in ros-perception/image_common

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.