Created
December 14, 2018 09:53
ROS bag to images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rosbag | |
from cv_bridge import CvBridge, CvBridgeError | |
import cv2 | |
# Input : A ros-bag | |
# Output : Save the image msg as individual images. Edit as appropriate. | |
bag = rosbag.Bag('banana.bag') | |
for topic, msg, t in bag.read_messages(topics=['/mynteye/right/image_raw']): | |
# print msg | |
stamp = str(msg.header.stamp) | |
cv_image = CvBridge().imgmsg_to_cv2(msg ) | |
print cv_image.shape | |
cv2.imshow( 'win', cv_image ) | |
cv2.waitKey(30) | |
print stamp+'.jpg' | |
cv2.imwrite( 'right/%s.jpg' %(stamp), cv_image ) | |
bag.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment