Skip to content

fix: modify data type of output segmentation mask to int64_t#49

Merged
ktro2828 merged 1 commit intomainfrom
fix/segmentation/data-type
Sep 27, 2025
Merged

fix: modify data type of output segmentation mask to int64_t#49
ktro2828 merged 1 commit intomainfrom
fix/segmentation/data-type

Conversation

@ktro2828
Copy link
Copy Markdown
Owner

Description

This pull request updates the SemanticSegmenter2D class to handle output masks as int64_t (64-bit integers) instead of int (typically 32-bit), ensuring consistency in data types across CUDA device memory, host memory, and postprocessing. It also updates the way output masks are converted for use with OpenCV.

Data type consistency and memory handling:

  • Changed the device output pointer output_d_ in SemanticSegmenter2D from int[] to int64_t[] to ensure the output mask uses 64-bit integers throughout the CUDA pipeline.
  • Updated CUDA memory allocation and memory copy operations to use int64_t instead of int, both in device memory allocation (cuda::make_unique<int64_t[]>) and host-side vectors (std::vector<int64_t>), and adjusted the cudaMemcpy size accordingly. [1] [2]

Postprocessing and OpenCV compatibility:

  • Refactored the postprocessing step to convert int64_t class IDs to unsigned char when creating OpenCV cv::Mat masks, replacing the previous method of casting a vector and using memcpy with an explicit per-element conversion loop. This ensures correct conversion and avoids issues with direct memory reinterpretation.

Code hygiene:

  • Added additional standard library headers (<chrono>, <map>, <sstream>, <thread>) to semantic_segmenter2d.cpp, likely for future use or consistency.

How was this PR tested?

Notes for reviewers

None.

Effects on system behavior

None.

Copilot AI review requested due to automatic review settings September 27, 2025 23:25
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

This PR updates the SemanticSegmenter2D class to use 64-bit integers (int64_t) consistently throughout the CUDA memory pipeline and postprocessing operations, replacing the previous 32-bit integer (int) implementation.

  • Changed CUDA device memory allocation and operations to use int64_t instead of int
  • Updated postprocessing to explicitly convert int64_t class IDs to unsigned char for OpenCV compatibility
  • Added standard library headers for future use

Reviewed Changes

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

File Description
mmros/src/detector/semantic_segmenter2d.cpp Updated CUDA memory operations to use int64_t, refactored postprocessing conversion logic, and added standard library includes
mmros/include/mmros/detector/semantic_segmenter2d.hpp Changed output_d_ member variable type from int[] to int64_t[]

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

Comment thread mmros/src/detector/semantic_segmenter2d.cpp Outdated
Comment thread mmros/src/detector/semantic_segmenter2d.cpp Outdated
Comment thread mmros/src/detector/semantic_segmenter2d.cpp Outdated
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
@ktro2828 ktro2828 force-pushed the fix/segmentation/data-type branch from db2d492 to 8a31da7 Compare September 27, 2025 23:39
@ktro2828 ktro2828 merged commit a7893d4 into main Sep 27, 2025
1 check failed
@ktro2828 ktro2828 deleted the fix/segmentation/data-type branch September 27, 2025 23:39
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