18 cv::Size
size = {0, 0};
72 long requiredSize = CV_ELEM_SIZE(
type) *
size.area();
73 long actualSize =
static_cast<long>(
img.
data.size());
74 if(actualSize < requiredSize) {
75 throw std::runtime_error(
"ImgFrame doesn't have enough data to encode specified frame, required " +
std::to_string(requiredSize) +
", actual "
76 +
std::to_string(actualSize) +
". Maybe metadataOnly transfer was made?");
77 }
else if(actualSize > requiredSize) {
82 throw std::runtime_error(
"ImgFrame metadata not valid (width or height = 0)");
90 std::memcpy(mat.data,
img.
data.data(), std::min((
long)(
img.
data.size()), (
long)(mat.dataend - mat.datastart)));
104 cv::cvtColor(frame, output, cv::ColorConversionCodes::COLOR_RGB2BGR);
108 output = frame.clone();
113 std::vector<cv::Mat> channels;
115 channels.push_back(cv::Mat(s, CV_8UC1,
getData().
data() + s.area() * 2));
116 channels.push_back(cv::Mat(s, CV_8UC1,
getData().
data() + s.area() * 1));
117 channels.push_back(cv::Mat(s, CV_8UC1,
getData().
data() + s.area() * 0));
118 cv::merge(channels, output);
123 std::vector<cv::Mat> channels;
125 channels.push_back(cv::Mat(s, CV_8UC1,
getData().
data() + s.area() * 0));
126 channels.push_back(cv::Mat(s, CV_8UC1,
getData().
data() + s.area() * 1));
127 channels.push_back(cv::Mat(s, CV_8UC1,
getData().
data() + s.area() * 2));
128 cv::merge(channels, output);
132 cv::cvtColor(frame, output, cv::ColorConversionCodes::COLOR_YUV2BGR_IYUV);
136 cv::cvtColor(frame, output, cv::ColorConversionCodes::COLOR_YUV2BGR_NV12);
140 cv::cvtColor(frame, output, cv::ColorConversionCodes::COLOR_YUV2BGR_NV21);
150 output = frame.clone();
154 output = frame.clone();