Good point. In general there are 2 ways. a) Convert from ROS to openCV data types at the beginning of segmentExecuteCB and then use the latter all the way before you return from the function. Or b) only make ROS to openCV conversion right before an openCV function is called and make the back conversion right after the function returns. In this case you'd then mostly work ROS data types in your code. Both approaches have their own pro and con traits.