Filtering depth data of the form sensor_msgs/Image from Kinect 2
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