feat(BEVFusion): add gpu-based image undistortion to the bevfusion node#12279
feat(BEVFusion): add gpu-based image undistortion to the bevfusion node#12279KSeangTan wants to merge 33 commits intoautowarefoundation:mainfrom
Conversation
Signed-off-by: Kok Seang <kseangtan@gmail.com>
Signed-off-by: Kok Seang <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
|
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds a camera image undistortion + preprocessing path to the BEVFusion camera-lidar pipeline by introducing per-camera GPU preprocessing objects and wiring them through the node and TensorRT runner.
Changes:
- Introduce
CameraData/CameraMatricesand a CUDA camera preprocessing implementation (remap/undistort + resize/crop + optional channel flip). - Refactor
BEVFusionNodeandBEVFusionTRTto pass/useCameraDatainstead of raw image/camera-info buffers. - Add new ROS parameters (
run_image_undistortion,flip_image_channels) and update launch/config wiring accordingly; remove the old ROI resize kernel from the generic preprocess module.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| perception/autoware_bevfusion/src/bevfusion_node_utils.cpp | Builds per-camera objects and updates intrinsics/mask handling to use CameraData. |
| perception/autoware_bevfusion/src/bevfusion_node.cpp | Declares new preprocessing params and routes image/camera_info callbacks into CameraData. |
| perception/autoware_bevfusion/lib/preprocess/preprocess_kernel.cu | Removes the old image ROI resize kernel from the generic preprocess CUDA module. |
| perception/autoware_bevfusion/lib/camera_matrices.cpp | Adds a CameraMatrices implementation (but duplicates the lib/camera/ version). |
| perception/autoware_bevfusion/lib/camera/camera_preprocess_kernel.cu | Adds CUDA remap (undistortion) and fused resize/crop kernel used per camera. |
| perception/autoware_bevfusion/lib/camera/camera_matrices.cpp | Implements camera intrinsics/distortion handling and undistortion map upload to GPU. |
| perception/autoware_bevfusion/lib/camera/camera_data.cpp | Implements per-camera message storage and GPU preprocessing orchestration. |
| perception/autoware_bevfusion/lib/bevfusion_trt.cpp | Refactors image preprocessing to use CameraData (per-camera streams/buffers). |
| perception/autoware_bevfusion/launch/bevfusion.launch.xml | Renames launch args for camera topics and keeps remaps consistent. |
| perception/autoware_bevfusion/include/autoware/bevfusion/preprocess/preprocess_kernel.hpp | Removes the old ROI resize API from PreprocessCuda. |
| perception/autoware_bevfusion/include/autoware/bevfusion/camera/camera_preprocess.hpp | Declares the new camera preprocessing CUDA API. |
| perception/autoware_bevfusion/include/autoware/bevfusion/camera/camera_matrices.hpp | Declares CameraMatrices and device-side undistortion maps. |
| perception/autoware_bevfusion/include/autoware/bevfusion/camera/camera_data.hpp | Declares CameraData and ImagePreProcessingParams. |
| perception/autoware_bevfusion/include/autoware/bevfusion/bevfusion_trt.hpp | Updates TRT interfaces to accept CameraData instead of raw image vectors. |
| perception/autoware_bevfusion/include/autoware/bevfusion/bevfusion_node.hpp | Stores per-camera objects and updates subscriber initialization signature. |
| perception/autoware_bevfusion/config/ml_package_bevfusion_lidar.param.yaml | Adds flip_image_channels parameter for lidar-only package config. |
| perception/autoware_bevfusion/config/ml_package_bevfusion_camera_lidar.param.yaml | Adds flip_image_channels parameter for camera-lidar package config. |
| perception/autoware_bevfusion/config/bevfusion_lidar.param.yaml | Adds run_image_undistortion toggle (false) for lidar-only config. |
| perception/autoware_bevfusion/config/bevfusion_camera_lidar.param.yaml | Adds run_image_undistortion toggle (true) for camera-lidar config. |
| perception/autoware_bevfusion/CMakeLists.txt | Wires new camera sources into the build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
perception/autoware_bevfusion/lib/camera/camera_preprocess_kernel.cu
Outdated
Show resolved
Hide resolved
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12279 +/- ##
==========================================
+ Coverage 18.49% 18.92% +0.42%
==========================================
Files 1855 1893 +38
Lines 129017 130102 +1085
Branches 45872 48352 +2480
==========================================
+ Hits 23864 24619 +755
- Misses 85382 86241 +859
+ Partials 19771 19242 -529
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Kok Seang Tan <kseangtan@gmail.com>
Description
This PR introduces a new feature to
BEVFusionto run gpu-based image undistortion in the node, which is the same implementation inautoware_camera_streampetr.This PR also slightly refactors and reorganizes the code structure as the prerequisite to separate the BEVFusion node according to the task type, for example,
BEVFusion_camera,BEVFusion_camera_lidarandBEVFusion_lidar. Note that the refactoring will be done in another PR.Specifically, it makes the following main changes:
run_image_undistortiontobevfusion_camera_lidar.param.yamlandperception/autoware_bevfusion/config/bevfusion_lidar.param.yamlto enable/disableimage_undistortion. [1], [2]flip_image_channelstoperception/autoware_bevfusion/config/ml_package_bevfusion_camera_lidar.param.yamlandperception/autoware_bevfusion/config/ml_package_bevfusion_lidar.param.yamlto flip image channels in preprocessing. [3], [4]camera_data.hppandcamera_data.cppas a data structure to preprocess/save image data in cpu/gpu. [5], [6]camera_metrices.hppandcamera_matrices.cppto precompute camera undistortion. [7], [8]camera_preprocessing.hppandcamera_preprocessing.cppto handle everything related to image preprocessing kernels [9], [10]initializeSensorFusionSubscribersto constructcamera_matricesandcamera_data[11]image_preprocessing_paramsinbevfusion_node[12]image_msgs_andcamera_info_msgs_bycamera_data_ptrs_andcamera_matrices_ptrs_, respectively. [13]imageCallbackinbevfusion_nodeto updatecamera_data_ptrs_instead ofimage_msgs_. [14]cameraInfoCallbackto updatecamera_data_ptrs_instead ofcamera_info_msgs_. [15]image_msgsbycamera_data_ptrsinbevfusion_trtto accepth the new inputs [16], [17]How was this PR tested?
Examples
Before
After
ROS Parameter Changes
Additions and removals
run_image_undistortionboolfalseflip_image_channelsbooltrue