4 from dynamic_reconfigure.server
import Server
5 from jsk_perception.cfg
import DepthImageFilterConfig
as Config
6 from jsk_topic_tools
import ConnectionBasedTransport
9 from sensor_msgs.msg
import Image
15 super(DepthImageFilter, self).
__init__()
20 '~output/mask', Image, queue_size=1)
24 queue_size=1, buff_size=2**24)
37 supported_encodings = {
'16UC1',
'32FC1'}
38 if depth_img_msg.encoding
not in supported_encodings:
39 rospy.logwarn(
'Unsupported depth image encoding: {0}'
40 .format(depth_img_msg.encoding))
42 depth = bridge.imgmsg_to_cv2(depth_img_msg)
43 if depth_img_msg.encoding ==
'16UC1':
44 depth = depth / 1000.0
46 mask = np.zeros(depth.shape, dtype=np.uint8)
47 mask_idx = np.logical_and(
51 mask_idx = np.logical_not(mask_idx)
54 mask = (mask).astype(np.uint8)
55 mask_msg = bridge.cv2_to_imgmsg(mask, encoding=
'mono8')
56 mask_msg.header = depth_img_msg.header
60 if __name__ ==
'__main__':
61 rospy.init_node(
'depth_image_filter')