0

I need to apply a warpping affine model to NV12 image.

Here is the format of NV12, the Y is separated from the Cb Cr. Cb Cr is interleaved.

enter image description here

The model looks like

[a11, a12, xt

a21, a22, yt]

a** are the rotation, xt yt are the shit.

This model is for Y planar.

Since Cb Cr are interleaved I think I can not directly apply the same model to CB CR (interleaved).

My questions is how can I apply the correct the warp affine to the Cb Cr and output the correct image(colorful).

BigTree
  • 23
  • 1
  • 4
  • What language, OS, tools? – Mark Setchell Apr 28 '20 at 18:41
  • @MarkSetchell I am trying to use C to implement this . – BigTree Apr 28 '20 at 19:44
  • In case it's still relevant... You need to apply Cb (and Cr) warp with `xt/2` and `yt/2`. In case you are using library function (like OpenCV) for the warp, you need to convert the interleaved CbCr to Cb matrix and Cr matrix, apply the warp and interleave the results. – Rotem Jul 18 '20 at 22:38

1 Answers1

0
cv::Mat src_y_mat(src_h, src_w, CV_8UC1, src_data, src_s);
cv::Mat dst_y_mat(dst_h, dst_w, CV_8UC1, dst_data, dst_s);
cv::warpAffine(src_y_mat, dst_y_mat, trans_mat, cv::Size(dst_w, dst_h),
                               cv::INTER_LINEAR, cv::BORDER_CONSTANT, border_value);
trans_mat.at<float>(0, 2) = trans_mat.at<float>(0, 2) / 2;
trans_mat.at<float>(1, 2) = trans_mat.at<float>(1, 2) / 2;
cv::Mat src_uv_mat(src_h / 2, src_w / 2, CV_8UC2, src_data1, src_s1);
cv::Mat dst_uv_mat(dst_h / 2, dst_w / 2, CV_8UC2, dst_data1, dst_s1);
cv::warpAffine(src_uv_mat, dst_uv_mat, trans_mat, cv::Size(dst_w / 2, dst_h / 2),
                               cv::INTER_LINEAR, cv::BORDER_CONSTANT, border_value);
nxdong
  • 1