Opencv Imwrite and Copy

Does anyone know how to save a Mat image as a .jpg file in C++? We have tried imwrite but cannot get Eclipse to recognize the function.

Also is there a way to copy one Mat image to another?

Sometimes eclipse gives you fake errors in C++. Try putting in an imwrite (make sure to #include the opencv header) and actually build it, ignoring eclipse’s instant feedback. Does g++ give you errors?

We use imwrite() with no problem. As previously stated, it is likely just an Eclipse issue, or a problem with your #includes.

For copying, try clone():

cv::Mat source;
//...GrabFrame(source) or whatever...
cv::Mat dst = source.clone();

Okay the clone is compiling okay and cv::imwrite(“test.jpg”, out_image) is also compiling. It looks like the third parameter for imwrite is not needed.
Thanks for your help. I will try this tonight.