将 ROS bag 数据批量转换为帧图像和 MP4 视频,并提供基于 OpenCV 的预标注与 Labelme 微调辅助工具链。
git clone git@github.com:xinyiqin/bag_file_process.git
cd bag_file_process
https://www.docker.com/products/docker-desktop
docker --version
docker pull osrf/ros:noetic-desktop-full
docker run -it --name "bag_process" -v F:/intel:/workspace osrf/ros:noetic-desktop-full
sed -i 's|http://archive.ubuntu.com/ubuntu/|https://mirrors.tuna.tsinghua.edu.cn/ubuntu/|g' /etc/apt/sources.list
apt-get update -qq && apt-get install -y -qq python3-pip ffmpeg > /dev/null 2>&1 && pip3 install opencv-python numpy
cd workspace
python3 /code/bag_to_video.py /$BAG_FILE -o /workspace/$OUTPUT_DIR
例子:
python3 /code/bag_to_video.py /bag_files/20251103test.bag -o /output
脚本会在输出目录下生成 images/frame_000000.png 等图像帧,再合成 output.mp4。
docker start -ai bag_process
python3 code/bag_to_video.py $BAG_FILE -o $OUTPUT_DIR
python3 code/bag_to_video.py --batch $DIR_BAG_FILES -o $OUTPUT_DIR
例子:
python3 code/bag_to_video.py --batch bag_files -o output
(不在docker里了,在外面的终端运行)
$DATA_DIR换成上面output文件夹下的具体数据文件夹
python code/pre_label.py $DATA_DIR
例子:
python code/pre_label.py output/20251103test
pip install labelme
labelme $IMAGE_DIR --output $LABELME_DIR
例子:
labelme output/20251103test/images --output output/20251103test/labelme
python code/labelme_to_yolo.py $DATA_DIR
例子:
python code/labelme_to_yolo.py output/20251103test
