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

Add function to convert single channel image data to RGB image #205

Merged
merged 7 commits into from
Apr 27, 2021

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Apr 23, 2021

🎉 New feature

Summary

Used by gazebosim/gz-gui#212 and gazebosim/gz-launch#112

Added a generic helper function for converting single channel image data, e.g. thermal and depth images, to an RGB image. This is intended to be used for visualization. Optional arguments can be specified to tweak the visualization.

Test it

The corresponding PRs in ign gui updates the Image Display to use this new function: gazebosim/gz-gui#212

You can test this together with that PR by running the sensors_demo.sdf world to see the visualization in Image Display

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge

iche033 added 4 commits April 22, 2021 19:02
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
@iche033 iche033 requested a review from mjcarroll as a code owner April 23, 2021 20:56
@github-actions github-actions bot added 🏰 citadel Ignition Citadel 🔮 dome Ignition Dome labels Apr 23, 2021
@codecov
Copy link

codecov bot commented Apr 23, 2021

Codecov Report

Merging #205 (90eba51) into ign-common3 (cdfbe87) will increase coverage by 0.12%.
The diff coverage is 97.05%.

Impacted file tree graph

@@               Coverage Diff               @@
##           ign-common3     #205      +/-   ##
===============================================
+ Coverage        75.08%   75.20%   +0.12%     
===============================================
  Files               72       73       +1     
  Lines            10273    10307      +34     
===============================================
+ Hits              7713     7751      +38     
+ Misses            2560     2556       -4     
Impacted Files Coverage Δ
graphics/include/ignition/common/Image.hh 97.05% <97.05%> (ø)
graphics/src/Image.cc 67.08% <0.00%> (+2.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdfbe87...90eba51. Read the comment docs.

T v = static_cast<T>(buffer[i]);
if (v > max && !std::isinf(v))
max = v;
if (v < min && !std::isinf(v))
Copy link
Contributor

Choose a reason for hiding this comment

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

Windows is not happy about these isinf calls with uint8_t:

Compiler error

C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\corecrt_math.h(409): error C2668: 'fpclassify': ambiguous call to overloaded function
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\corecrt_math.h(300): note: could be 'int fpclassify(long double) noexcept'
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\corecrt_math.h(295): note: or       'int fpclassify(double) noexcept'
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\corecrt_math.h(290): note: or       'int fpclassify(float) noexcept'
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt\corecrt_math.h(409): note: while trying to match the argument list '(_Ty)'
        with
        [
            _Ty=uint8_t
        ]
C:\Jenkins\workspace\ignition_common-ci-pr_any-windows7-amd64\ws\ign-common\graphics\include\ignition/common/Image.hh(226): note: see reference to function template instantiation 'bool isinf<T>(_Ty) noexcept' being compiled
        with
        [
            T=uint8_t,
            _Ty=uint8_t
        ]
C:\Jenkins\workspace\ignition_common-ci-pr_any-windows7-amd64\ws\ign-common\graphics\src\Image_TEST.cc(351): note: see reference to function template instantiation 'void ignition::common::Image::ConvertToRGBImage<uint8_t>(const void *,unsigned int,unsigned int,ignition::common::Image &,T,T,bool)' being compiled
        with
        [
            T=uint8_t
        ]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\xstring(1739): note: see reference to class template instantiation 'std::basic_string_view<char,std::char_traits<char>>' being compiled

Signed-off-by: Ian Chen <ichen@osrfoundation.org>
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
@iche033 iche033 requested a review from ahcorde April 26, 2021 18:30
Copy link
Contributor

@mjcarroll mjcarroll left a comment

Choose a reason for hiding this comment

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

An approach to remove new/delete as well as the raw pointers: #206

Signed-off-by: Michael Carroll <michael@openrobotics.org>
Copy link
Contributor

@mjcarroll mjcarroll left a comment

Choose a reason for hiding this comment

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

LGTM

@mjcarroll mjcarroll enabled auto-merge (squash) April 27, 2021 12:25
@mjcarroll mjcarroll merged commit 9f26057 into ign-common3 Apr 27, 2021
@mjcarroll mjcarroll deleted the convert_rgb branch April 27, 2021 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏰 citadel Ignition Citadel 🔮 dome Ignition Dome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants