Closed meyerj closed 1 year ago
Thanks for the contribution @meyerj! I agree with the changes, and wonder why the numbers were off-by-one before... :thinking:
Thanks for the contribution @meyerj! I agree with the changes, and wonder why the numbers were off-by-one before... thinking
Likely because C programmers are used to add one more element to arrays for a terminating null character ;-) Or maybe it even had to be like that in older versions of OpenCV, too...
The number of elements in vector params needs to be even (cv::imencode(), cv::imwrite()).
OpenCV version 4.7 complains if the vector has an odd number of elements, like 3 or 9: https://github.com/opencv/opencv/commit/f0df78b7e743a8d735a4bc669ae64a155f08645d#diff-c43d1948c31949b9c25dea5c7f019e1bfed04d98ee9fb1a97f7b1b98dd9b5525R718
The
reserve()
+emplace_back()
approach has been adapted from therolling
branch, where the bug has already been fixed in the same way in https://github.com/ros-perception/image_transport_plugins/commit/7ca907277eda51ec2fbb71409bda33d1395d6127.