Works more or less, but seems that wrapping incoming buffers in cv::Mat does not go too well, better to wrap in IplImageHeader then create a cv::Mat on the spot. On passing back to output iplimage, some stride is ignored in the conversions.