ros-perception / ros-perception/image_common

image_transport::SubscriberFilter decodes 16bit png to 8bit

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

Nobody has claimed this yet.

Dominant language
C++
Stars
153
Forks
253
Avg merge
5m
Merged PRs (30d)
1

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.

Contributor guide

No contributing guide indexed for this repository

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.

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.