8 from pcl_msgs.msg
import PointIndices
11 from sensor_msgs.msg
import Image
19 '~output/indices', PointIndices, queue_size=1)
20 self.
pub_img = rospy.Publisher(
'~output/image', Image, queue_size=1)
22 '~input/mask1', Image, self.
mask_cb, callback_args=
'mask1')
24 '~input/mask2', Image, self.
mask_cb, callback_args=
'mask2')
30 for name
in [
'mask1',
'mask2']:
34 bridge = cv_bridge.CvBridge()
36 imgmsg = bridge.cv2_to_imgmsg(np.zeros((30, 30), dtype=np.uint8),
38 indices_msg = PointIndices()
39 indices_msg.indices = np.arange(10, 30)
40 while self.msg.get(name)
is None:
41 imgmsg.header.stamp = indices_msg.header.stamp = rospy.Time.now()
42 self.pub_indices.publish(indices_msg)
43 self.pub_img.publish(imgmsg)
46 mask_in = bridge.imgmsg_to_cv2(
47 self.
msg[name], desired_encoding=
'mono8')
48 mask_in = np.squeeze(mask_in)
49 mask_expected = np.zeros((imgmsg.height, imgmsg.width), dtype=np.uint8)
50 mask_expected.ravel()[np.arange(10, 30)] = 255
51 np.testing.assert_array_equal(mask_in, mask_expected)
54 if __name__ ==
"__main__":
55 PKG =
'jsk_pcl_ros_utils' 56 ID =
'test_point_indices_to_mask_image' 58 rostest.rosrun(PKG, ID, TestPointIndicesToMaskImage)
def _test_each_conversion(self, name)
def mask_cb(self, msg, name)
def test_conversion(self)