ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Extract last 2 frames from camera

asked 2021-06-23 19:38:50 -0500

guiaugustoga gravatar image


How do I extract multiple frames from a video streaming using ROS ?

I subscribed to my camera topic :

 self.image_sub = rospy.Subscriber('/bebop2/image_raw',Image, self.image_callback)

And then :

frame = self.bridge.imgmsg_to_cv2(msg,desired_encoding='bgr8')

This way I have the actual frame from my streaming. How can I store N frames (the actual and previous ones) ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-06-24 02:28:56 -0500

gvdhoorn gravatar image

This can be done using either local variables (ie: store incoming messages in variables in the scope outside the callback), or (and this would be preferable): use message_filters/Cache:

Stores a time history of messages.

Given a stream of messages, the most recent N messages are cached in a ring buffer, from which time intervals of the cache can then be retrieved by the client. The timestamp of a message is determined from its header field.

You tagged this rospy, but just to mention them: fkie_message_filters offers an improved version of message_filters but is C++, and fetchrobotics/flow_ros is an even more complex/complete implementation of something which could still be considered similar to message_filters.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-06-23 19:38:50 -0500

Seen: 48 times

Last updated: Jun 24 '21