Ask Your Question
0

Filtering depth data of the form sensor_msgs/Image from Kinect 2

asked 2015-12-30 17:43:13 -0600

Naman gravatar image

updated 2016-01-04 09:15:48 -0600

Hi all,

--See Update 1--

I am using iai_kinect2 to get a depth cloud in the form sensor_msgs/Image. Now, I want to filter this depth cloud (like remove points on the ground, outliers, etc.). I can use a Pass-through filter but it works only on sensor_msgs/PointCloud2 whereas I have sensor_msgs/Image. Now, my question is :

1) I can convert sensor_msgs/Image to sensor_msgs/PointCloud2 using depth_image_proc and do filtering but then, how can I convert the filtered Pointcloud (in form sensor_msgs/Pointcloud2) back to depth cloud (in form sensor_msgs/Image) to use it with depthimage_to_laserscan ?

2) Or, How can I directly filter depth_cloud in the form sensor_msgs/Image using pass-through filters, etc.. ?

3) I know I can use pointcloud_to_laserscan to convert filtered_pointcloud to laser scan but it will be less efficient and therefore, I want to know how can I do the above conversion or directly filter the depth_cloud?

Update 1 :
As suggested by @Akif, I used pcl:toROSMsg to convert sensor_msgs/PointCloud2 to sensor_msgs/Image. It compiled properly but during run time, when I try to visualize it in RVIZ, I get the following :

MessageFilter [target=kinect2_link ]: Discarding message from [unknown_publisher] due to empty frame_id.  This message will only print once.

When I do rostopic echo /kinect2/depthcloud_filtered, I get

header: 
  seq: 2139
  stamp: 
    secs: 0
    nsecs: 0
  frame_id: ''
height: 1
width: 68227
encoding: bgr8
is_bigendian: 0
step: 204681
data: [0, 0, 181, 209, 216, 179, 207, 214, 179, 207, 214, 0, 0, 0, 175, 204, 211, 176, 205, 212, 176, 205, 210, 177, 206, 211, 0, 0, 0, 0, 0, 0, 179, 207, 214, 179, 208, 215, 181, 210, 217, 0, 0, 0, 178, 207, 214, 179, 208, 215, 180, 209, 216, 175, 204, 209, 175, 205, 210, 174, 203, 210, 0, 0, 0, 174, 203, 210, 175, 204, 211, 174, 203, 210, 176, 204, 211, 177, 205, 212, 0, 0, 0, 178, 207, 212, 180, 209, 214, 178, 206, 213, 179, 208, 215, 177, 209, 215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 209, 216, 174, 203, 208, 174, 203, 208, 176, 205, 210, 174, 203, 208, 175, 204, 209, 175, 205, 210, 175, 205, 210, 175, 204, 211, 175, 204, 211, 173, 205, 211, 172, 204, 210, 173, 205, 211, 173, 205, 211, 176, 205, 212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 179, 208, 215, 171, 203, 209, ....... ]

It looks like there is some problem here. It does not have any time stamp or frame_id. Does anyone has any idea why is this happening? Any suggestions will be helpful.

Thanks in advance.
Naman Kumar

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-01-01 08:16:20 -0600

Akif gravatar image

I will answer through your 1) option.

In PCL we have pcl_conversions header. With help of it, you can use ::toROSMsg to convert sensor_msgs/PointCloud2 to sensor_msgs/Image.

Also there is a tutorial on this. Hope this helps.

edit flag offensive delete link more

Comments

@Akif! ::toROSMsg extracts the RGB image from the depth cloud. I just want to convert the format of depth cloud to sensor_msgs/Image from sensor_msgs/PointCloud2.. like iai_kinect2 ros package publishes depth cloud as sensor_msg/Image.. Please correct me if I am wrong! TIA

Naman gravatar imageNaman ( 2016-01-01 14:21:47 -0600 )edit

Hi.. I have updated my original question. Thanks!

Naman gravatar imageNaman ( 2016-01-04 09:16:31 -0600 )edit

Hi Naman, could plz get me starting to use kinect v2 for detecting the object and depth data, I have installed everything, but I don't know how to run, cuz all codes for kinect v1

Abdu gravatar imageAbdu ( 2017-05-19 09:16:04 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-12-30 17:43:13 -0600

Seen: 940 times

Last updated: May 19 '17