iai_kinect2
iai_kinect2 copied to clipboard
Program Stuck when subscribe both image_color and image_depth topic in one node (python)
trafficstars
I have a problem when i subscribe both RGB and depth topic in one node. At the beginning the program runs properly, but after about 10 second, it will stuck and not to receive any further message.
def callback(color,depth):
rospy.loginfo('Receive the %s RGB image' %color.header.seq)
rospy.loginfo('Receive the %s Depth image' %depth.header.seq)
cv2_img = bridge.imgmsg_to_cv2(color, "bgr8")
cv2_depth = bridge.imgmsg_to_cv2(depth, "16UC1")
cv2.imshow('RGB',cv2_depth)
cv2.imshow('RGB',cv2_depth)
k = cv2.waitKey(1)
if k == 27: # wait for ESC key to exit
cv2.destroyAllWindows()
def reader():
rospy.init_node('reader_RGB',anonymous=True)
color_sub = message_filters.Subscriber('kinect2/sd/image_color_rect',Image)
depth_sub = message_filters.Subscriber('kinect2/sd/image_depth_rect',Image)
ts = message_filters.TimeSynchronizer([color_sub,depth_sub], 5)
ts.registerCallback(callback)
rospy.spin()
But if I don't imshow it in the callback(), the program will run continuously.