i need to convert a mat to iplimage and back, in order to draw a line. My code so far:
Mat mat = imread(path);
Point p,q;
...
imwrite(path1,mat1);
IplImage img = mat1;
cvDrawLine(&img,p,q,Scalar(0,0,255));
mat1 = Mat(&img); //i also tried mat1=&img;
imwrite(path2,mat1);
the first imwrite works, but at the second, i get an exception. Any ideas?
You can use
cv::cvarrToMatto convertCvMat,IplImage, orCvMatNDtoMat.For your case, it will be like:
PS: As commented by @Miki, you should avoid obsolete C OpenCV APIs. Using C++ APIs, it will simply be: