# parse_rosbag **Repository Path**: sesameking/parse_rosbag ## Basic Information - **Project Name**: parse_rosbag - **Description**: 将bag中标定文件、图片等信息解析出来 - **Primary Language**: C++ - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-07 - **Last Updated**: 2025-05-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 统一工具链 ## 1.环境准备 **Notice:** 当前准备工作都集成到“2.编译”中第一行命令中,执行即可。可跳过下述说明。 VDC回放镜像容器中,安装CI上的最新X86软件包。(至少包含3rdparty、msg和framework三个仓库) >>> **注意**: 这个文件夹最好在ubuntu20.04系统下执行。 ```sh sudo apt install ros-base-dev ``` 安装 lz4 压缩bag算法的python的库 ```shell pip3 install --upgrade pycryptodome lz4 pip3 install roslz4 --extra-index-url https://rospypi.github.io/simple/ ``` ros的指令基本是可以用了,可以用rosbag指令试一下查看bag的信息: ```shell rosbag info test.bag ``` ## 2.编译 - 第一次运行,执行下面命令 ```sh bash setup.bash build_all ``` - 如果后面重复编译,则执行下面命令 ```sh bash setup.bash ``` - 清空构建文件夹,则执行 ```sh bash setup.bash clean ``` - 查看帮助 ```sh bash setup.bash -h Usage: setup.bash [OPTION1]... Compile the project. Default parameter is EMPTY. [-h | --help] Show help message [build_all] Use build_all if first build the project to build env dependence. [clean] Remove build files. Example: 1. bash setup.bash clean 2. bash setup.bash build_all 3. bash setup.bash ``` 编译成功后,可执行文件在build路径下。 ## 3.转换 ### 3.1 原始数据包 将需要转换的集成HDS数据包放到`bagToRsclbag_tools/input_data`目录下 转换时,会**批量转换该文件夹下所有bag数据包**。 **注意:** 转换之前,确保结果文件夹下没有该数据包转换的历史结果。 ### 3.2 转换 #### 3.2.1 基本转换 ```sh bash data_transformation.sh ``` 该命令会将HDS数据包,转换为商汤可回灌的 rscl 数据包、视频流文件和标定文件。 #### 3.2.2 基本转换 + both | crop_resize | crop | resize 图片同时转出 ```sh bash data_transformation.sh -m | --mode [OPTIONAL1] ``` - `OPTIONAL1` 可选为: `both` | `resize` | `crop` | `resize_crop` | `pvb` 。`both`表示同时输出`resize`和`crop`图像。`pvb`等同于`both`,会在程序结束之后,运行python脚本,生成PVB需要的json文件 - **选项中输入`resize_crop` 与 `crop_resize` 效果相同!** #### 3.2.3 仅转换 crop_resize | crop | resize 图片,不转 rscl 包 ```sh bash data_transformation.sh -m | --mode [OPTIONAL1] ``` - `OPTIONAL1` 可选为: `only_resize` | `only_crop` | `only_resize_crop` | `only_both`。`only_both`表示仅同时输出`resize`和`crop`图像 #### 3.2.4 时间过滤功能 在上述功能基础上,对一段时间范围内的数据进行过滤输出,不必全量包转换 ```sh bash data_transformation.sh -m [OPTIONAL1] -s [Start-Time] -e [End-Time] ``` - `OPTIONAL1` 为上述转换模式:null | resize | crop | resize_crop | only_resize | only_crop | only_resize_crop **注意:**如果参数里有起止时间戳,则转换模式必填! - `Start-Time` 格式为: `YYYYMMDD_hhmmss_xxx` 或者时间戳格式 `1234567890.123` - `End-Time` 格式为: `YYYYMMDD_hhmmss_xxx` 或者时间戳格式 `1234567890.123` 命令示例: ```sh 1. bash data_transformation.sh -m crop -s 20250408_143611_106 -e 20250408_143612_405 2. bash data_transformation.sh -m null -s 1744094171.106 -e 1744094172.405 ``` #### 3.2.5 指定输入和输出文件路径 如果不使用默认路径,则可以指定输入文件夹和输出文件夹 ```bash bash data_transformation.sh -i [input path] -o [output path] ``` 命令示例: ```bash bash data_transformation.sh -m both -i /home/Randy -o /home/Output/SanJie ``` #### 3.2.6 查看帮助 ```sh bash data_transformation.sh -h Usage: data_transformation [OPTION]... [FILE]... Usage: data_transformation -m [mode] -s [start time] -e [end time] -i [input path] -o [output path]... Convert the integrated bag package to an RSCL package, which can be filtered by time。 -m, --mode [Optional] Input mode of processing Options: null (default) | pvb | both | resize | crop | resize_crop | only_resize | only_crop | only_resize_crop | only_both means no output images, option starts with only_ means only output images. -s, --start_time [Optional] Start time of filtering Example: 20250408_143611_106 | 1744094171.106 -e, --end_time [Optional] End time of filtering Example: 20250408_143612_405 | 1744094172.405 -i, --input [Optional] Input data directory, input_data default. -o, --output [Optional] Output data directory, output_data default. Example: 1. bash data_transformation.sh 2. bash data_transformation.sh -m resize 3. bash data_transformation.sh -m both 4. bash data_transformation.sh -m only_crop -s 20250408_143611_106 -e 20250408_143612_405 5. bash data_transformation.sh -m both -s 1744094171.106 -e 1744094172.405 6. bash data_transformation.sh -m both -i input_data -o output_data ``` ### 3.3 转换结果 - 转换结束会在`result` 路径下 - 可以通过 `rsclbag info dmppcl.00000.rsclbag` 查看信息。 - 转换结果文件夹:`bagToRsclbag_tools/output_data`。如果之前转换过原始数据包,且没有清除,则后续转换结果会在`bagToRsclbag_tools/result`文件夹下。结果路径下生成 dmppcl.00000.rsclbag, h264, txt, 和标定文件 - 如果有导出图片,则会在对应文件夹下建立 `resize` | `crop` | `resize_crop` 文件夹存放对应帧图片。