ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Depthimage_to_laserscan - choose which part of the image is scanned [closed]

asked 2014-07-24 09:23:26 -0600

anamcarvalho gravatar image

updated 2014-08-02 18:30:11 -0600

Hi everyone!

I am using the package depthimage_to_laserscan. In this package is possible to change the parameter scan height to 480 (the height of the kinect depth image).

What I wanted to do is the following: I want the to obtain three 2D planes, instead of just one. For this to happen I need to divide the kinect depth image in 3, and scan each 1/3 of the image separately. So, I want one 2D scan for the bottom 1/3 of the kinect depth image, one for the top 1/3 and one for the center 1/3.

The problem is that when setting the scan height, even if I give it the value of 480/3, it will scan 480/3 rows, starting from the center of the image, meaning I can't get the top 1/3 scan and neither the bottom 1/3 scan!

How can I do this?

I hope my explanation wasn't very confusing! I would be grateful if you could help me on this issue!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by anamcarvalho
close date 2014-08-25 12:08:57.341582

Comments

I have the same issue and I don't know what to do

arenillas gravatar image arenillas  ( 2014-08-01 10:55:21 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2014-08-20 01:34:21 -0600

MarkyMark2012 gravatar image

updated 2014-08-20 01:36:11 -0600

If I read your question correctly you want to have three laser scans, one for the top, middle and bottom of the image? If so I'd suggest updating the package so that

void convert(const sensor_msgs::ImageConstPtr& depth_msg, const image_geometry::PinholeCameraModel& cam_model, const sensor_msgs::LaserScanPtr& scan_msg, const int& scan_height, int& imageOffset)

takes a new parameter - imageOffset or something which would be used to shift the horzontal center.

Details on the Image can be found here http://docs.pointclouds.org/1.5.1/structsensor__msgs_1_1_image.html

Then start three different depthimage_to_laser scan nodes, mapping the output to say /scan_top, /scan_middle and /scan_bottom where the imageOffset parameter is shifted to the 1/3 area of which ever bit you want.

Of course you could further extend the process to publish these topics diectly - but if the above is what you're looking for it'll give you a starting point

Cheers

Mark

edit flag offensive delete link more

Comments

Thanks Mark! It worked!

anamcarvalho gravatar image anamcarvalho  ( 2014-08-25 12:08:49 -0600 )edit

Cool! :) pleased to help

MarkyMark2012 gravatar image MarkyMark2012  ( 2014-08-25 13:58:14 -0600 )edit

@anamcarvalho, can you guide me through editing DepthImageToLaserScan.h with that new offset parameter? I want to try something quite similar with my kinect.

charkoteow gravatar image charkoteow  ( 2014-09-09 22:55:17 -0600 )edit
1

Hi @charkoteow, what I did was use the offset as a pointer to the area I wanted to scan! I wanted 3 scans for 3 different areas, so I needed 3 different depthimage_to_laserscan... I simply changed the name of the topic each one provided and changed the following line of the code:

anamcarvalho gravatar image anamcarvalho  ( 2014-10-02 11:51:26 -0600 )edit
1

int offset = (int)(cam_model.cy()-scan_height/2 - scan_height); This allows me to point to the first horizontal 1/3 of the kinect image! To point to the bottom 1/3 just change the last subtraction to a sum, and you will point to the center of the bottom area! cam_model.cy provides the center of img!

anamcarvalho gravatar image anamcarvalho  ( 2014-10-02 11:51:37 -0600 )edit

Thank you @anamcarvalho it's working now.

charkoteow gravatar image charkoteow  ( 2014-10-07 07:04:50 -0600 )edit

Im confused with your answer @Mark, you say shift the horizontal center, wouldnt it be the vertical center? The reason I want to use this is for some reason my Asus xtion uses the bottom pixels for the scan and not the center ones. I would like to force it to use the center pixels? any suggestions

miguel gravatar image miguel  ( 2015-10-04 16:19:26 -0600 )edit

@miguel - was this fixed by the flip issue?

MarkyMark2012 gravatar image MarkyMark2012  ( 2015-10-07 09:00:40 -0600 )edit
0

answered 2014-07-24 21:38:21 -0600

I am afraid you can not accomplish what you need with depthimage_to_laserscan. The parameter scan height, does not mean "the row on the image to take as laser scan", it means "how many rows from the center of the image to consider when transforming to laser scan"

As you can see on the implementation of the function that does the conversion.

But, the good news is, you can create your own custom package based on depthimage_to_laserscan to achieve your goal.

edit flag offensive delete link more

Comments

Hi Martin, I never said that, I even said "starting from the center of the image"... What I wanted to do was change the depthimage_to_laserscan package, creating one of my own, changing that function you mentioned! The problem is, I don't know how and I was hoping someone knew!

anamcarvalho gravatar image anamcarvalho  ( 2014-07-25 07:40:53 -0600 )edit

Hi anamcarvalho

Could you please provide the code which worked for you? Thanks a lot

zeinab gravatar image zeinab  ( 2014-10-01 10:37:54 -0600 )edit

Hi @zeinab, what I did was use the offset as a pointer to the area I wanted to scan! I wanted 3 scans for 3 different areas, so I needed 3 different depthimage_to_laserscan... I simply changed the name of the topic each one provided and changed the following line of the code:

anamcarvalho gravatar image anamcarvalho  ( 2014-10-02 11:49:07 -0600 )edit
2

int offset = (int)(cam_model.cy()-scan_height/2 - scan_height); This allows me to point to the first horizontal 1/3 of the kinect image! To point to the bottom 1/3 just change the last subtraction to a sum, and you will point to the center of the bottom area! cam_model.cy provides the center of img!

anamcarvalho gravatar image anamcarvalho  ( 2014-10-02 11:51:03 -0600 )edit

Thanks a lot for your help

zeinab gravatar image zeinab  ( 2014-10-06 11:18:49 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2014-07-24 09:23:26 -0600

Seen: 2,668 times

Last updated: Aug 20 '14