11 from sensor_msgs.msg
import Image
12 from cv_bridge
import CvBridge, CvBridgeError
18 arguments_size = len(arguments)
19 if arguments_size == 0:
20 print(
"Usage: bag_images_extract.py bag_file_name [images_directory]")
25 if arguments_size >= 2:
26 directory = arguments[1]
29 bag_file_name = arguments[0]
30 bag = rosbag.Bag(bag_file_name)
34 topic_name =
"/fiducials_localization/interesting_images" 37 for topic, msg, t
in bag.read_messages(topic_name):
41 cv_image = bridge.imgmsg_to_cv(msg, desired_encoding=
"rgb8")
42 except CvBridgeError, e:
46 cv.SaveImage(
"{0}/Image{1:03d}.pnm".format(directory, index), cv_image)
49 if previous_time ==
None:
51 dt = t - previous_time
53 print(
"[{0}]:{1}".format(index, dt))