Skip to content

refactor: add a function for preprocessing image#59

Merged
ktro2828 merged 4 commits intomainfrom
refactor/detector/preprocess-image
Oct 2, 2025
Merged

refactor: add a function for preprocessing image#59
ktro2828 merged 4 commits intomainfrom
refactor/detector/preprocess-image

Conversation

@ktro2828
Copy link
Copy Markdown
Owner

@ktro2828 ktro2828 commented Oct 2, 2025

Description

This pull request refactors the image preprocessing pipeline for various detector modules in the project. The main change is the introduction of a new unified preprocessing function, preprocess_image, which streamlines and replaces the previous manual, repetitive preprocessing code across multiple detectors. This improves maintainability and reduces code duplication. Additionally, the low-level GPU kernel function declarations have been moved to a dedicated header file for better organization.

Refactoring and code organization:

  • Added the new process::preprocess_image function in mmros/process/image.hpp to provide a unified interface for image preprocessing on the GPU. This function replaces the manual memory allocation and kernel calls previously present in each detector module.
  • Moved all low-level GPU kernel function declarations (such as resizing, letterboxing, format conversion, normalization, and argmax) from image.hpp to the new mmros/process/image_kernel.hpp file for better separation of concerns and code clarity.

Detector module simplification:

  • Updated the preprocess methods in Detector2D, InstanceSegmenter2D, PanopticSegmenter2D, and SemanticSegmenter2D to use the new process::preprocess_image function, removing manual buffer management and direct kernel calls. [1] [2] [3]
  • Removed unnecessary includes and manual CUDA memory management code from detector source files, further simplifying and cleaning up the codebase. [1] [2] [3] [4]

License and header updates:

  • Updated the copyright notice in image.hpp to reflect the new author and year.

These changes collectively improve code maintainability, readability, and modularity, making it easier to extend or modify preprocessing logic in the future.

How was this PR tested?

  • Confirmed build passed
  • Confirmed some projects worked

Notes for reviewers

None.

Effects on system behavior

None.

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Copilot AI review requested due to automatic review settings October 2, 2025 21:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Refactors image preprocessing pipeline by introducing a unified preprocess_image function and reorganizing GPU kernel declarations for better code maintainability and reduced duplication.

  • Introduced process::preprocess_image function to replace duplicated preprocessing code across detector modules
  • Moved low-level GPU kernel declarations from image.hpp to new image_kernel.hpp for better separation of concerns
  • Simplified all detector modules by removing manual buffer management and direct kernel calls

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
mmros/src/process/image.cpp New implementation of unified preprocessing function
mmros/include/mmros/process/image.hpp Refactored to include new preprocessing function and remove kernel declarations
mmros/include/mmros/process/image_kernel.hpp New header containing all GPU kernel function declarations
mmros/src/process/image_kernel.cu Updated include to reference new kernel header
mmros/src/detector/*.cpp Simplified preprocessing by using new unified function

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread mmros/src/process/image.cpp Outdated
Comment thread mmros/src/process/image.cpp Outdated
ktro2828 and others added 2 commits October 3, 2025 06:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ktro2828 ktro2828 merged commit 45c183a into main Oct 2, 2025
1 check failed
@ktro2828 ktro2828 deleted the refactor/detector/preprocess-image branch October 2, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants