OpenCV cvtColor appears to not work correctly on iOS with internet meeting. When calling cvtColor two occasions in a row, the second run delivers fallacious outcomes. Utilizing the next code snippet I can reproduce the difficulty:
void testCvtImage()
{
cv::Mat consequence(2048, 1365, CV_8UC4, cv::Scalar(125, 170, 255, 255));
cv::Mat m;
cv::cvtColor(consequence, m, cv::ColorConversionCodes::COLOR_RGBA2BGRA);
std::cout << "Dimensions of m: " << m.cols << "x" << m.rows << " pixelvalue:" << static_cast<int>(m.at<cv::Vec4b>(0,0)[0]) << std::endl;
std::cout << "Beginning grey picture testing" << std::endl;
cv::Mat grayRGB(2048, 1365, CV_8UC3, cv::Scalar(128, 128, 128));
cv::Mat grayRGBA;
cv::cvtColor(grayRGB, grayRGBA, cv::ColorConversionCodes::COLOR_BGR2BGRA);
for (int row=0; row<grayRGB.rows; ++row) {
for (int col=0; col<grayRGB.cols; ++col) {
auto v1 = grayRGB.at<cv::Vec3b>(row, col);
auto v2 = grayRGBA.at<cv::Vec4b>(row, col);
if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) {
std::cout << "Non matching pixel discovered!" << std::endl;
}
}
}
std::cout << "Completed grey picture testing" << std::endl;
}
Some particulars of my construct setup:
- Conan 1.60.0
- Emscripten 3.1.31
- OpenCV 4.5.5
I used to be capable of reproduce the difficulty on a number of totally different iOS units in Chrome in addition to in Safari. I did not handle to breed it on any desktop browser although.
On iOS units, the std::cout << "Non matching pixel discovered!" << std::endl;
output was proven hundreds of occasions. When visually inspecting the defective transformed picture, it had common vertical inexperienced stripes everywhere in the picture. When inspecting the RGB values, it confirmed that each one defective pixels have the RGB worth (0, 128, 0, 255).
Does somebody have a touch on why this might occur?