代码中的 OpenCV 错误
OpenCV error in code
我的代码上出现以下两个错误。
'img.cv::Mat::cols' 不能用作函数
'img.cv::Mat::rows' 不能用作函数
我不知道如何解决它。有人可以帮我解决此错误吗?
这是我的代码
using namespace std;
using namespace cv;
void salt(Mat &img,int saltvalue)
{
for(int k=0;k<saltvalue;k++)
{
int i = rand() % img.cols();
int j = rand() % img.rows();
img.at<Vec3b>(j,i)[0]=255;
img.at<Vec3b>(j,i)[1]=255;
img.at<Vec3b>(j,i)[2]=255;
}
}
int main()
{
Mat img;
img = imread("C:\castle.jpg",CV_LOAD_IMAGE_UNCHANGED);
salt(img,3000);
namedWindow("vOut",CV_WINDOW_AUTOSIZE);
imshow("vOut",img);
waitKey(0);
destroyAllWindows();
return 0;
}
cols
和rows
是Mat
类的成员整数,而不是成员函数。删除()
:
int i = rand() % img.cols;
int j = rand() % img.rows;
尝试:
int i = rand() % img.cols;
int j = rand() % img.rows;
img.cv::Mat::cols 和 img.cv::Mat::rows 似乎是属性,而不是该类的方法。
相关文章:
- 如何修复"未定义的引用"错误 opencv 和 g++
- 链接错误 Opencv Qt '_ZN2cv6String10deallocateEv
- 错误 opencv 错误断言失败 (p [-1] <= 2) 是什么意思以及如何处理它?
- 错误:OpenCV 3.4.0 CUDA ORB 功能检测
- 调试断言错误-OpenCV
- 在 Ubuntu 中选择超时错误 - Opencv
- 内存不足错误Opencv/c++
- 'Corrupted double-linked list'内存错误 - OpenCV-Python 3.0.0 和 ARM 上的 Numpy
- 链接错误 OpenCV 仅在使用 -wl,-rpath,/usr/local/MATLAB/R2014b/bin/gln
- 人脸跟踪错误 Opencv
- 致命错误:opencv/cvtypes.h:没有终止此类文件或目录编译
- Sobel 边缘检测错误(OpenCV 错误:断言失败 (DIMS<=2&&Data&&(无符号)i0)
- 我正在尝试将灰度转换为更大的黑色图像.我得到这个错误OpenCV错误:断言失败
- 分段错误 - OpenCV 和 Qt in Netbeans on Ubuntu
- Visual Studio 2013中C++中的VideoCapture错误OpenCV 3.0.0
- 如何修复内存不足错误(openCV)
- 错误 OpenCV 在 C++ 中支持 CUDA
- 图像轮廓检测错误:OpenCV,C++
- c++分割错误OpenCV
- 编译错误opencv