Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean code for Image display #1271

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

penww
Copy link
Contributor

@penww penww commented Aug 26, 2024

Some cleanup:

  • Considering duplicated code in multiple places, using a common function to handle YUV to RGB pixel conversion.
  • Using std::clamp() instead of clamp expressions.

@penww penww requested a review from ahcorde as a code owner August 26, 2024 09:45
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

I'm worried here about the performance, we should call this function twice for everypixel. Did you compare the performance ? maybe we should use inline?

@penww
Copy link
Contributor Author

penww commented Aug 30, 2024

@ahcorde Thanks for your suggestion. I ignored the performance impact of function calls, will change it to inline.

I will continuelly work on ImageDisplay to support more YUV format, such as nv12, nv24 etc.

BTW, eventhough it is inline, convert color for every pixel is not efficient, especially when image is large.
Can we consider to convert with OpenGL / OpenMP? I can have a try on it.

@penww penww force-pushed the penww/rolling/image_display branch from d628df0 to d1483b3 Compare August 30, 2024 09:19
@penww
Copy link
Contributor Author

penww commented Aug 30, 2024

Has pushed new patch to change this function to inline.

  • I also compared std::clamp with ((i & 0xFFFFFF00) == 0) ? i : (i < 0) ? 0 : 0xFF, it shows std::clamp faster.
  • And checked std::tie, it shows no more extra performance cost.

In O2 compile option, std::clamp and std::tie are faster than old code. I think compiler making optimization for std functions.

@penww penww requested a review from ahcorde August 30, 2024 09:42
@zycczy
Copy link

zycczy commented Oct 12, 2024

Hi @ahcorde
Is there any update for this PR

@ahcorde
Copy link
Contributor

ahcorde commented Oct 14, 2024

Pulls: #1271
Gist: https://gist.githubusercontent.com/ahcorde/3e98ba46a6470006da49fd65022f8c58/raw/02f480667308172745d5283f9da22dc37754cf03/ros2.repos
BUILD args: --packages-above-and-dependencies rviz_default_plugins --packages-above-and-dependencies rviz_default_plugins
TEST args: --packages-above rviz_default_plugins --packages-above rviz_default_plugins
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/14700

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

Do you mind to merge with rolling ?

@ahcorde
Copy link
Contributor

ahcorde commented Oct 15, 2024

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@ahcorde ahcorde merged commit f7112b1 into ros2:rolling Oct 15, 2024
2 checks passed
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.

3 participants