cv::Mat::zeros(img.size(),CV_8UC3);
时间: 2024-06-01 15:10:25 浏览: 10
This line of code creates a new `cv::Mat` object with dimensions equal to `img` and initializes all its values to zero. The `CV_8UC3` parameter specifies the data type of the matrix as an 8-bit unsigned integer with 3 channels (corresponding to the Red, Green, and Blue color channels). This can be useful for creating a blank image of the same size and color format as another image, which can then be used as a canvas for drawing or processing operations.
相关问题
pha = cv::Mat::zeros(img_size, CV_64FC1); B = cv::Mat::zeros(img_size, CV_64FC1);di==第一句通过第二句报错
这个错误可能是因为你没有定义 `img_size`,或者 `img_size` 的值不正确,导致 `cv::Mat::zeros()` 函数无法正确地创建一个大小为 `img_size` 的矩阵。
你可以检查一下 `img_size` 的定义和赋值是否正确,或者在创建 `cv::Mat` 对象时直接指定矩阵的大小,例如:
```
cv::Mat pha = cv::Mat::zeros(cv::Size(640, 480), CV_64FC1);
cv::Mat B = cv::Mat::zeros(cv::Size(640, 480), CV_64FC1);
```
这样可以直接指定矩阵的大小为 640x480。
Mat img(channels, cv::Size(width, height), CV_32F, data); 这行报错 error: no matching function for call to ‘cv::Mat::Mat(const int&, cv::Size, int, float [460800])’
这个错误的原因是 `cv::Size` 的构造函数需要传入两个 `int` 类型的参数,而你传入的第一个参数是 `channels`,它的类型是 `int`,所以编译器认为你正在调用一个不存在的构造函数。你可以尝试将 `channels` 和 `cv::Size` 的参数分别传入构造函数,如下所示:
```
Mat img(cv::Size(width, height), CV_32F);
img = Mat::zeros(height, width, CV_32F);
```
然后再将 `data` 中的数据赋值给 `img` 即可。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)