Это мой первый неработающий подход в C ++ с OpenCV: < /p>
Код: Выделить всё
cv::Mat tmpMat = Mat::zeros(dst.rows, dst.cols, dst.type());
// Debayering from RCCG to RCG
cv::demosaicing(src, tmpMat, cv::ColorConversionCodes::COLOR_BayerBG2RGB);
float R{};
float C{};
float G{};
float Y{};
float Cr{};
float Cg{};
for (int row = 0; row < tmpMat.rows; row++)
{
for (int col = 0; col < tmpMat.cols; col++)
{
R = tmpMat.at(row, col)[0];
C = tmpMat.at(row, col)[1];
G = tmpMat.at(row, col)[2];
// Convert RCCG to YCrCg
Y = C;
Cr = C - 0.299F * R;
Cg = C - 0.587F * G;
// Convert YCrCg to YCrCb by swapping Cr and Cg
dst.at(row, col)[0] = static_cast(Y);
dst.at(row, col)[1] = static_cast(Cg);
dst.at(row, col)[2] = static_cast(Cr);
}
}
cv::cvtColor(dst, dst, cv::ColorConversionCodes::COLOR_YCrCb2BGR);
Подробнее здесь: https://stackoverflow.com/questions/772 ... ith-opencv
Мобильная версия