문제 설명
OpenCV는 YUV_420_888 평면에서 3개의 매트 개체를 만듭니다. (OpenCV create 3 mat objects from YUV_420_888 planes)
YUV_420_888 평면 데이터를 보유하기 위해 3개의 매트 개체를 생성할 수 있습니까? 하나는 Y, 다른 하나는 U, 마지막 하나는 V 평면입니다.
BGR이나 다른 것으로 변환하고 싶지 않고 위와 같이 데이터를 보관하십시오.
참조 솔루션
방법 1:
You can use Splitting of the Mat.
For example in a BGR Image (I'll show you in c++ because i'm not that into opencv4Android):
cv::Mat src = cv::imread("some.png");
cv::Mat planes[3];
cv::split(src, planes);
If you have a BGR you would now have the R‑Plane in the planes[2]
.
Another possibility is, to just get the Planes Buffer e.g.(Java Android now):
/* Get your Image somehow */
Image.Plane Y = img.getPlanes[0];
Image.Plane U = img.getPlanes[1];
Image.Plane V = img.getPlanes[2];
//now just for Y e.g.
ByteBuffer yBuffer = Y.getBuffer();
byte[] yBytes = new Byte[yBuffer.remaining()];
yBuffer.get(yBytes);
//read the byte data into a cv::Mat
(by user2179256、Marcel T)