The code below causes an exception. Why?
#include
#include
using namespace cv;
using namespace std;
void mai
Mat img;
img=Mat::zeros(size of image,CV_8UC3);
if you want it to be of an image img1
img=Mat::zeros(img1.size,CV_8UC3);
Because the last parameter is optional and also the data pointer should point somewhere appropriate:
//inline Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
double mydata[1];
Mat m1 = Mat(1,1, CV_64F, mydata);
m1.at<double>(0,0) = 0;
But better do it directly with this template-based constructor:
//inline Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
Mat m1 = Mat(1,1, CV_64F, cvScalar(0.));
//or even
Mat m1 = Mat(1,1, CV_64F, double(0));