Qt6中出现 OpenCV(4.10.0) Error: Assertion failed
之前在编写Qt6的程序(运行于Windows 10上)时,出现了下列错误:
OpenCV(4.10.0) Error: Assertion failed ((unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())) in cv::Mat::at, file H:\OpenCV\opencv\build\include\opencv2/core/mat.inl.hpp, line 899
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.10.0) Error: Assertion failed ((unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())) in cv::Mat::at, file H:\OpenCV\opencv\build\include\opencv2/core/mat.inl.hpp, line 899
检查程序后发现是我Mat对象的类型设置有误,
把
Mat FalseColor = Mat::zeros(img.rows*4, img.cols, CV_8UC1);
改成
Mat FalseColor = Mat::zeros(img.rows*4, img.cols, CV_8UC3);
即刻运行成功