Skip to content

Leave to YARP the pixel code (channel order) conversion aligned with OpenCV (BGRx)#44

Merged
nunoguedelha merged 3 commits into
masterfrom
refact/i43-use-yarp-toCvMat-pixel-code-conversion
Apr 17, 2022
Merged

Leave to YARP the pixel code (channel order) conversion aligned with OpenCV (BGRx)#44
nunoguedelha merged 3 commits into
masterfrom
refact/i43-use-yarp-toCvMat-pixel-code-conversion

Conversation

@nunoguedelha
Copy link
Copy Markdown
Collaborator

Implements #43 .

@nunoguedelha
Copy link
Copy Markdown
Collaborator Author

This is a first attempt to use yarp::sig::toCvMat function for converting the pixel code for aligning it with the default channel order used by OpenCV.

There is a problem with the definition of the map yarpCode2toCvMat: for adding another line with a different pixel code (e.g. yarp::sig::PixelMono), I would need to have a generic type x in the declaration of the map, which accepts both yarp::sig::PixelMono and yarp::sig::PixelRgb (like a "union"). Same applies to all the other lines in yarpCode2toCvMat still commented. Using a parent class of ImageOf, i.e. Image doesn't seem to work.

…s the implementation

- This allows to avoid having to select a specialisation of `yarp::cv::toCvMat` depending on the pixel code, and instead, always use the specialization `yarp::cv::toCvMat<yarp::sig::PixelBgr>` respective to the destination image.
- The drawback is that we loose the alpha channel, as per the actual implementation of `yarp::sig::Image::copy`.
@nunoguedelha nunoguedelha marked this pull request as ready for review April 15, 2022 21:30
@nunoguedelha nunoguedelha requested a review from traversaro April 15, 2022 21:31
@nunoguedelha
Copy link
Copy Markdown
Collaborator Author

CC @S-Dafarra @RiccardoGrieco

@nunoguedelha
Copy link
Copy Markdown
Collaborator Author

There is a problem with the definition of the map yarpCode2toCvMat: for adding another line with a different pixel code (e.g. yarp::sig::PixelMono), I would need to have a generic type x in the declaration of the map, which accepts both yarp::sig::PixelMono and yarp::sig::PixelRgb (like a "union"). Same applies to all the other lines in yarpCode2toCvMat still commented. Using a parent class of ImageOf, i.e. Image doesn't seem to work.

This problem was avoided. Refer to #43 .

Copy link
Copy Markdown
Member

@traversaro traversaro left a comment

Choose a reason for hiding this comment

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

Cool!

@nunoguedelha nunoguedelha merged commit 08c9c2c into master Apr 17, 2022
@nunoguedelha
Copy link
Copy Markdown
Collaborator Author

Side note:
I selected "Squash and merge" but it kept the old commits and created a new merge commit, just as if I had chosen "Create new merge commit".
CC @traversaro

@nunoguedelha nunoguedelha deleted the refact/i43-use-yarp-toCvMat-pixel-code-conversion branch April 17, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants