def callback(data):
"""Callback function for subscribing to an Image topic and creating a buffer
"""
global dtype
global images_so_far
# Get cv image (which is a numpy array) from data
cv_image = bridge.imgmsg_to_cv2(data)
# Save dtype before we float32-ify it
dtype = str(cv_image.dtype)
# Insert and roll buffer
buffer.insert(0, (np.asarray(cv_image, dtype='float32'), rospy.get_time()))
if(len(buffer) > bufsize):
buffer.pop()
# for showing framerate
images_so_far += 1
# Initialize subscriber with our callback
评论列表
文章目录