-
Notifications
You must be signed in to change notification settings - Fork 38
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 API for getting Image bytes as std::vector #372
Conversation
Signed-off-by: Luca Della Vedova <luca@openrobotics.org>
Signed-off-by: Luca Della Vedova <luca@openrobotics.org>
There's a new deprecation warning, we should update
|
Signed-off-by: Luca Della Vedova <luca@openrobotics.org>
Done thanks! |
Codecov Report
@@ Coverage Diff @@
## main #372 +/- ##
==========================================
+ Coverage 77.85% 77.93% +0.08%
==========================================
Files 85 85
Lines 10783 10823 +40
==========================================
+ Hits 8395 8435 +40
Misses 2388 2388
Continue to review full report at Codecov.
|
I'm happy with this, but I think we should fix usage up the stack before merging to avoid introducing a whole bunch of deprecation warnings. I would propose fixing those first, or if you are constrained for time, removing the deprecations until we get cycles to fix the warnings. |
Agreed, that's pretty trivial and I actually prepared all the branches a few days ago, I didn't open the PRs to avoid making too much noise until this was in a "good enough state". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this once CI looks good.
We can cut a release and get the downstream PRs unblocked then.
Only failure is a known flaky test on MacOS. |
Getting this in for nightlies so that others can merge tomorrow am. |
🎉 New feature
Closes #369
Summary
This PR adds a new API for
common::Image
to get the data as anstd::vector<unsigned char>
and deprecates the API where the user is expected to pass a pointer, a length and free the memory manually.There is a fair bit of code duplication, I was trying to come up with a way to reuse some code but it would have probably made deprecation harder in the future.
For example I thought of having the std::vector version of the function just copy the raw array returned by the
Data
functions but that would have required refactoring when they are removed. In alternative I could have the oldData
functions just allocate a C array and copy the std::vector's data, but now their performance would get quite a bit worse (need two allocations instead of one)"Thanks to" the code duplication all the deprecated Data / DataImpl functions can be safely deleted and no visible behavior change should be exposed to the users.
Test it
All the unit tests with the old API have been converted to use the new API and are still successful. I also added a new test case for the deprecated functions to make sure the behavior between the old and the new ones is exactly the same (all the bytes match). The deprecated tests have deprecation warning silencing to avoid cluttering the build output and are in a separate test case so they can be easily removed in the future.
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.