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

Unable to read PPM produced by opencv #14

Open
suyash023 opened this issue Jun 20, 2019 · 3 comments
Open

Unable to read PPM produced by opencv #14

suyash023 opened this issue Jun 20, 2019 · 3 comments

Comments

@suyash023
Copy link

Hello
I am using opencv 3.4.2 and ros kinetic. I installed the imagezero plugin for image_transport package via apt-get. When I try to subscribe to the /camera/depth_registered/sw_registered/image_rect_raw/imagezero topic I get the following error

[ERROR] [1561044796.104110050]: Unable to read PPM produced by OpenCV. First few bytes: P5

How to go about resolving this?

Suyash

@pjreed
Copy link

pjreed commented Jun 20, 2019

Do you know if this issue happens with OpenCV 3.3.1? It looks like that is currently the default version for Ubuntu 16.04 / ROS Kinetic. Also, how is the source image being encoded? (You can run rostopic echo -n 1 --noarr /camera/depth_registered/sw_registered/image_rect_raw and then just copy/paste the details from there)

It looks like that error happens on the compression side, after it uses OpenCV to encode a PPM image, it checks to see if the header is valid: https://github.com/swri-robotics/imagezero_transport/blob/master/imagezero/src/portableimage.cpp#L84

The "P5" there looks like it produced a single-channel PPM, but one of the width/height/max value checks after that must have failed. If you're comfortable building it from source, it might be useful to put some debug logging in there to see what it is reading for those values. However, it should be noted that the ImageZero algorithm only supports 24-bit (aka three-channel) PPM images -- if the source is actually a single-channel (grayscale) image, it can't compress it.

@suyash023
Copy link
Author

Thanks for the valueable feedback! I think you rightly pointed the issue of the "P5" header indicating a single channel image. It is indeed a single channel 16 bit grayscale image, since the values obtained from the depth camera are 16 bit. I tried using the compressedDepth image transport plugin and I am able to obtain 15 fps at max (which is mainly due to the slow compression of png), while for RGB I am able to obtain 30 fps which is also the original fps. Can you suggest something for 16 bit image transport apart from compressedDepth.

@pjreed
Copy link

pjreed commented Jun 20, 2019

I'm not aware of anything that was designed specifically for grayscale images, although I see that StarskyRobotics made a fork of this repo and made some modifications to allow the algorithm to process images with any number of channels: https://github.com/StarskyRobotics/imagezero_transport

It looks like it's probably considerably less efficient for non-24-bit images, but it still might be worth a try to see how well it works for you.

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