ipa320 / softkinetic

This repository holds a ROS driver package for an interactive gesture camera (softkinetic).
23 stars 40 forks source link

Image is wrongly formed #25

Closed jdddog closed 10 years ago

jdddog commented 10 years ago

When I subscribe to the softkinetic camera's image topic I try to copy the image message with OpenCV and get an error (see below). This same code works for normal webcams.

cv_bridge::CvImagePtr cv_ptr = cv_bridge::toCvCopy(image_msg, sensor_msgs::image_encodings::BGR8);

I get this error:

terminate called after throwing an instance of 'cv_bridge::Exception' what(): Image is wrongly formed: step < width * byte_depth * num_channels or 0 != 1280 * 1 * 3

Any ideas?

corot commented 10 years ago

Yes, I saw the problem. I'll PR the fix soon. Meantime, you can patch your code. Add the missing image.step on line 155, like:

    image.width = w;///2;
    image.height = h;///2;
    image.step = w*3;

This should fix the problem, but tell me if not.

jdddog commented 10 years ago

Awesome thanks :D

jdddog commented 10 years ago

By the way, is the rgb_data image topic rectified? And if not, what do I need to do to rectify it?

corot commented 10 years ago

Nope, afaik. But another softkinetic user send me this version of the code including calibration.

https://www.dropbox.com/s/m19y4yvgyr98lju/softkineticDemo.zip?dl=0

You need to change 'file:///home/haduong/calib/senz3d.yaml' (line 659). You can calibrate the senz3d by yourself or use my calibration file. (http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration)

Please report any feedback about using it, so we can incorporate your experiences on the "official code"

jdddog commented 10 years ago

Sweet thanks - that's so helpful! Would they mind if I pushed their code to my fork? Or do they already have one? (So other people collaborating with me can easily access it)

corot commented 10 years ago

I assume it's not a problem. That's mostly an experiment to use the senz3d as a laser scan. Feel free to do whatever, and contribute to the original repo!

2014-08-25 8:51 GMT+02:00 Jamie Diprose notifications@github.com:

Sweet thanks - that's so helpful! Would they mind if I pushed their code to my fork? Or do they already have one? (So other people collaborating with me can easily access it)

— Reply to this email directly or view it on GitHub https://github.com/ipa320/softkinetic/issues/25#issuecomment-53232764.

jdddog commented 10 years ago

Cool thanks :) Is your calibration file for a Creative Senze3D, or another Softkinetic product? And where is it?

jdddog commented 10 years ago

Actually dw, I found it in the workspace

gavanderhoorn commented 10 years ago

@jdddog: just to be clear: the code posted by @corot does not rectify the image itself, it 'just' adds the necessary CameraInfo publisher to the driver node, so that image_proc/rectify can do the work.

jdddog commented 10 years ago

Thanks, I was wondering how the actual rectification was done :)

If I want to project an image point (u,v) into the world that doesn't have a corresponding point in the point cloud, assuming I know the points depth, do I need to work from the rectified image or is rgb_data fine?

I notice that corot doesn't seem to rectify the image when mapping the image to points in the point cloud (correct me if I'm wrong), (from line 206 here: https://github.com/corot/softkinetic/blob/indigo-devel/softkinetic_camera/src/softkinetic_start.cpp). So I assume that I can just use rgb_data...

I was thinking of using the equation: x = DEPTH * (u - cx) / fx y = DEPTH * (v - cy) / fy z = DEPTH

gavanderhoorn commented 10 years ago

@jdddog: this is starting to turn into a forum thread. I think it'd be better if you created a question on ROS answers.

jdddog commented 10 years ago

Haha ok, I've created a question :)

corot commented 10 years ago

Also solved on indigo

ghost commented 6 years ago

Is this still a problem on ROS Kinetic with the cv_bridge::CvImage function toImageMsg()? I had this show up today when I'm trying to convert a .jpg file into the ROS pipeline through an intermediate cv::imread. If it's useful, I could paste snippets of my code here.

kalyco commented 4 years ago

Yes, I saw the problem. I'll PR the fix soon. Meantime, you can patch your code. Add the missing image.step on line 155, like:

    image.width = w;///2;
    image.height = h;///2;
    image.step = w*3;

This should fix the problem, but tell me if not.

This seems to cause the following issue Image is wrongly formed: height * step != size or 240 * 1272 != 203520 , for example. Before changing step to width my issue was displaying Image is wrongly formed: step < width * byte_depth * num_channels or 848 != 424 * 1 * 3 A potential alternative fix could be to set width from 424 to 282, but that's a 34% decrease..

For context I am trying to convert a depth image of encoding 16UC1 to BGR8