- #include <opencv2/opencv.hpp>
- #include <iostream>
- using namespace cv;
- using namespace std;
- int main() {
- int pic_height = 2;
- int pic_width = 2;
- {
- Mat alpha_map = Mat::ones(pic_height, pic_width, CV_32FC4);
- cout << "alpha_map = " << endl << alpha_map << endl;
- //alpha_map =
- // [1, 0, 0, 0, 1, 0, 0, 0;
- // 1, 0, 0, 0, 1, 0, 0, 0]
- }
- {
- Mat alpha_map = Mat::ones(pic_height, pic_width, CV_32FC4);
- alpha_map.setTo(1);
- cout << "alpha_map = " << endl << alpha_map << endl;
- //alpha_map =
- // [1, 1, 1, 1, 1, 1, 1, 1;
- // 1, 1, 1, 1, 1, 1, 1, 1]
- }
- {
- Mat alpha_map(pic_height, pic_width, CV_32FC4, Scalar(1.0, 1.0, 1.0, 1.0));
- cout << "alpha_map = " << endl << alpha_map << endl;
- //alpha_map =
- // [1, 1, 1, 1, 1, 1, 1, 1;
- // 1, 1, 1, 1, 1, 1, 1, 1]
- }
- return 0;
- }
复制代码 一直以为下面这样会将每个通道均初始化为1,导致一个bug调了半天根本没有怀疑过这里。
连deepseek和chatgpt也这样说,现实上只会对一个通道初始化。
Mat alpha_map = Mat: nes(pic_height, pic_width, CV_32FC4);
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |