@@ -38,6 +38,99 @@ Print total cumulative serialized message size per topic.
3838- ` -c ` , ` --csv ` : Output as CSV.
3939- ` -a ` , ` --sort-alphabetical ` : Sort by topic names (default is by topic sizes).
4040
41+ ### extract_images
42+
43+ Extract image topics from bag file to image or video files.
44+
45+ #### Usage
46+
47+ rosrun cras_bag_tools extract_images [-h] [--out-format OUT_FORMAT] [--verbose] bag_file output_dir [image_topics [image_topics ...]]
48+
49+ * ` bag_file ` : The bag to read.
50+ * ` output_dir ` : Directory where all generated files should be stored.
51+ * ` image_topics ` : Zero or more topics to convert. If zero, all image topics are converted. Each image topic can be
52+ followed by additional configuration in the form
53+ ` TOPIC:OUT_FORMAT:COMPRESSION:ENCODING:IN_FPS:OUT_FPS:PIX_FMT ` (only ` TOPIC ` is required)
54+ * ` OUT_FORMAT ` : Format of the exported images/video (e.g. ` jpg ` , ` mp4 ` etc.). Defaults to ` --out-format ` .
55+ * ` COMPRESSION ` : Compression level. The meaning depends on ` OUT_FORMAT ` . JPG has 0-100, PNG 0-9, MP4 0-51 (CRF).
56+ * ` ENCODING ` : Pixel format to convert the images to. E.g. ` bgr8 ` or ` mono8 ` . ` passthrough ` means keeping the format.
57+ Empty string retains the format for raw images and converts compressed images to the recorded raw format
58+ in their ` .format ` field if it is available. Defaults to ` passthrough ` .
59+ * Following options are for video formats only.
60+ * ` IN_FPS ` : Framerate of the topic images. If not set, it is estimated from the frequency of the messages in the bag.
61+ You can set the FPS higher than the original, effectively speeding up the video.
62+ * ` OUT_FPS ` : Output framerate. Defaults to ` IN_FPS ` .
63+ * ` PIX_FMT ` : The ` -pix_fmt ` output option for ffmpeg, i.e. the pixel format of the video stream. Defaults to
64+ ` yuvj420p ` .
65+ * ` -h ` : Shows help.
66+ * ` --out-format ` : Default format for all topics (e.g. ` jpg ` , ` mp4 ` etc.). Defaults to ` jpg ` .
67+ * ` --verbose ` : Print various details during execution.
68+
69+ #### Example command
70+
71+ ``` bash
72+ # Convert all image topics in the bag to a series of JPEG images in folder imgs/
73+ rosrun cras_bag_tools extract_images spot_2022-10-27-10-35-46.video.bag imgs
74+
75+ # Convert topic /rviz/fixed_image/compressed to an MP4 video
76+ rosrun cras_bag_tools extract_images spot_2022-10-27-10-35-46.video.bag . /rviz/fixed_image/compressed:mp4:23:passthrough:25
77+ ```
78+
79+ ### filter_bag
80+
81+ Process bag files with a configured set of filters.
82+
83+ #### Usage
84+
85+ usage: filter_bag [-h] [-c CONFIG [CONFIG ...]] [-o OUT_FORMAT] [--lz4] [--bz2] [--no-copy-params] [--list-yaml-keys] [--list-filters] [--merge-initial-static-tf [DURATION]]
86+ [--throttle TOPIC RATE [TOPIC RATE ...]] [-i INCLUDE_TOPICS [INCLUDE_TOPICS ...]] [-e EXCLUDE_TOPICS [EXCLUDE_TOPICS ...]] [--include-types INCLUDE_TYPES [INCLUDE_TYPES ...]]
87+ [--exclude-types EXCLUDE_TYPES [EXCLUDE_TYPES ...]] [--include-tf-parents INCLUDE_TF_PARENTS [INCLUDE_TF_PARENTS ...]]
88+ [--exclude-tf-parents EXCLUDE_TF_PARENTS [EXCLUDE_TF_PARENTS ...]] [--include-tf-children INCLUDE_TF_CHILDREN [INCLUDE_TF_CHILDREN ...]]
89+ [--exclude-tf-children EXCLUDE_TF_CHILDREN [EXCLUDE_TF_CHILDREN ...]] [--decompress-images] [--max-message-size MAX_MESSAGE_SIZE]
90+ [bags [bags ...]]
91+
92+
93+ Positional arguments:
94+
95+ * ` bags ` : The list of bags to process.
96+
97+ Optional arguments:
98+ * ` --list-yaml-keys ` : Print a list of all available YAML top-level keys provided by filters.
99+ * ` --list-filters ` : Print a list of all available filters.
100+ * ` --no-copy-params ` : If set, no .params file will be copied
101+ * ` -i INCLUDE_TOPICS [INCLUDE_TOPICS ...] ` , ` --include-topics INCLUDE_TOPICS [INCLUDE_TOPICS ...] ` : Retain only
102+ these topics
103+ * ` -e EXCLUDE_TOPICS [EXCLUDE_TOPICS ...] ` , ` --exclude-topics EXCLUDE_TOPICS [EXCLUDE_TOPICS ...] ` : Remove these topics
104+ * ` --include-types INCLUDE_TYPES [INCLUDE_TYPES ...] ` : Retain only messages of these types
105+ * ` --exclude-types EXCLUDE_TYPES [EXCLUDE_TYPES ...] ` : Remove messages of these types
106+ * ` --throttle TOPIC RATE [TOPIC RATE ...], --hz TOPIC RATE [TOPIC RATE ...] ` : Throttle messages. This argument should be
107+ an even-sized list of pairs ` [TOPIC RATE] ` .
108+ * ` --include-tf-parents INCLUDE_TF_PARENTS [INCLUDE_TF_PARENTS ...] ` : Retain only TFs with these frames as parents
109+ * ` --exclude-tf-parents EXCLUDE_TF_PARENTS [EXCLUDE_TF_PARENTS ...] ` : Remove TFs with these frames as parents
110+ * ` --include-tf-children INCLUDE_TF_CHILDREN [INCLUDE_TF_CHILDREN ...] ` : Retain only TFs with these frames as children
111+ * ` --exclude-tf-children EXCLUDE_TF_CHILDREN [EXCLUDE_TF_CHILDREN ...] ` : Remove TFs with these frames as children
112+ * ` --max-message-size MAX_MESSAGE_SIZE ` : Remove all messages larger than this size ` [B] `
113+ * ` --merge-initial-static-tf [DURATION] ` : Merge a few initial static TFs into one. DURATION specifies the duration of
114+ the initial bag section to be considered for the merging. DURATION defaults to 5 secs.
115+ * ` --decompress-images ` : Decompress all images
116+ * ` -c CONFIG [CONFIG ...] ` , ` --config CONFIG [CONFIG ...] ` : YAML configs of filters
117+ * ` -o OUT_FORMAT ` , ` --out-format OUT_FORMAT ` : Template for naming the output bag. Defaults to ` {name}.proc{ext} ` .
118+ Relative paths will put the bag relative to current directory (not relative to the location of the source bag).
119+ The format string can utilize variables ` dirname ` (directory of the source bag), ` name ` (name of the source bag
120+ without extension), ` ext ` (extension of the source bag (should be ` .bag ` )).
121+ * ` --lz4 ` : Compress the bag using LZ4 compression.
122+ * ` --bz2 ` : Compress the bag using BZ2 compression (warning: this compression is very slow).
123+
124+ The YAML config files can contain the same keys as the optional CLI arguments (list all of them via ` --list-yaml-keys ` .
125+ Additionally, YAML configs can contain key ` filters ` which is a list of additional filters. Each filter is defined as a
126+ dict with the filter class as key and filter configuration as value. See the ` config/ ` folder for examples. List all
127+ available filters via ` --list-filters ` .
128+
129+ Other filters can be defined by 3rd-party packages via pluginlib. The package has to
130+ ` <exec_depend>cras_bag_tools</exec_depend> ` and it has to put this line in its ` <export> ` tag in package.xml:
131+ ` <cras_bag_tools filters="$PACKAGE.$MODULE" /> ` . With this in place, ` filter_bag ` will search the specified module
132+ for all classes that subclass ` cras_bag_tools.MessageFilter ` and it will provide these as additional filters.
133+
41134### fix_msg_defs
42135
43136Sometimes it can happen that wrong textual definitions of messages are stored in bag files (although the MD5 sums are correct).
0 commit comments