Ask Your Question

How to save an image from OpenCV

asked 2014-07-07 06:42:08 -0500

brycemh gravatar image

updated 2014-07-07 06:44:05 -0500

Hey guys,

I wanted to know if there is a function that will allow me to save an image from opencv; for example, i wrote a program that will rotate an image 90 degrees. How can I save the rotated image to a folder?


edit retag flag offensive close merge delete


Check imwrite, also see an example here

Haris gravatar imageHaris ( 2014-07-07 06:44:52 -0500 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2014-07-07 06:46:18 -0500

It is pretty simple, look at the following snippet:

Mat original_image, rotated_image;
apply_rotation(original_image, rotated_image);
imwrite("/home/data/temp.png", rotated_image);

Next time you should take a look at the documentation first and try to format your question correctly.

edit flag offensive delete link more

answered 2014-07-07 06:45:32 -0500

thdrksdfthmn gravatar image

updated 2014-07-07 06:48:22 -0500

Yes, there is bool imwrite(const string& filename, InputArray img, const vector<int>& params=vector<int>() ) see documentation. There is bool imencode(const string& ext, InputArray img, vector<uchar>& buf, const vector<int>& params=vector<int>()), that is used by imwrite(...).

edit flag offensive delete link more


Hmmm weird that you should update your question if already 2 others gave a perfect example. Downside of trying to be fast and helpfull I guess :P

StevenPuttemans gravatar imageStevenPuttemans ( 2014-07-07 06:51:59 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2014-07-07 06:42:08 -0500

Seen: 164 times

Last updated: Jul 07 '14