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

ROS image message encoding mono16 #20

Open
lichunshang opened this issue Jun 18, 2019 · 1 comment
Open

ROS image message encoding mono16 #20

lichunshang opened this issue Jun 18, 2019 · 1 comment

Comments

@lichunshang
Copy link

lichunshang commented Jun 18, 2019

The Subscriber::imageCallback does not support mono16 encoding used in the TUM VIO dataset bag files. Images will end up looking like this:

image

when it should look like this:
image

{
const cv::Mat raw(msg->height, msg->width, CV_8UC1,
const_cast<uint8_t*>(&msg->data[0]), msg->step);

The solution is to use cv_bridge to make the conversion from ROS Image message to cv::Mat.

const cv::Mat raw = cv_bridge::toCvCopy(msg, "mono8")->image;

cv_bridge is already a dependency.

@tmako123
Copy link

tmako123 commented May 9, 2020

In my case, I replaced

cv::Mat filtered(msg1->height, msg1->width, CV_8UC1);
memcpy(filtered.data, &msg1->data[0], msg1->height * msg1->width);

with

const cv::Mat filtered = cv_bridge::toCvCopy(msg1, "mono8")->image;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants