当前位置:网站首页>Opencv scalar passes in three parameters, which can only be displayed in black, white and gray. Solve the problem

Opencv scalar passes in three parameters, which can only be displayed in black, white and gray. Solve the problem

2022-07-07 23:15:00 Wang Bai ~

The error code is :

cv::Mat img2(h, w, CV_8UC1, cv::Scalar(0, 255, 0));

scalar The three parameters passed in are BGR, The above function I want to generate is a green picture , However, what is actually produced is white .
The problem lies in the third parameter , Parameter is CV_8UC1 It means that the black-and-white gray pattern is generated . You need to change the parameter to CV_8UC3, This time can produce the correct results .

cv::Mat img2(h, w, CV_8UC3, cv::Scalar(0, 255, 0));
原网站

版权声明
本文为[Wang Bai ~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207072005142343.html