Imdecode function returns none

I am trying to compress image datas and send them using udp protocol but in final step, imdecode funtion returns empty array even though my vector is not empty. How can I fix this?

Tools: C++, Ros2 Foxy OS: Ubuntu 20.04

enter image description here

Best Regards,

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum