1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

MediaSDK: fixed Linux build, improved BGR<->NV12 conversions

This commit is contained in:
Maksim Shabunin
2017-10-26 15:03:53 +03:00
parent cc626a3b5a
commit 0c79f4a00f
6 changed files with 116 additions and 96 deletions
+4 -9
View File
@@ -5,6 +5,7 @@
#include "cap_mfx_reader.hpp"
#include "opencv2/core/base.hpp"
#include "cap_mfx_common.hpp"
#include "opencv2/imgproc/hal/hal.hpp"
using namespace cv;
using namespace std;
@@ -243,17 +244,11 @@ bool VideoCapture_IntelMFX::retrieveFrame(int, OutputArray out)
const int cols = info.CropW;
const int rows = info.CropH;
Mat nv12(rows * 3 / 2, cols, CV_8UC1);
Mat Y(rows, cols, CV_8UC1, data.Y, data.Pitch);
Mat UV(rows / 2, cols, CV_8UC1, data.UV, data.Pitch);
out.create(rows, cols, CV_8UC3);
Mat res = out.getMat();
Y.copyTo(Mat(nv12, Rect(0, 0, cols, rows)));
UV.copyTo(Mat(nv12, Rect(0, rows, cols, rows / 2)));
Mat u_and_v[2];
split(UV.reshape(2), u_and_v);
cvtColor(nv12, out, COLOR_YUV2BGR_NV12);
hal::cvtTwoPlaneYUVtoBGR(data.Y, data.UV, data.Pitch, res.data, res.step, cols, rows, 3, false, 0);
return true;
}