Ask Your Question
1

imwrite error

asked 2014-07-25 09:02:00 -0500

ROSkinect gravatar image

updated 2014-07-28 04:07:38 -0500

cv::imwrite("/home/jros/image.jpg",cv_ptr->image);

I want to save an image using imwrite but I get this error when I launch the node:

OpenCV Error: Unspecified error (could not find a writer for the specified extension) in imwrite_, file /home/guillaume/Developpement/libs/OpenCV-2.2.0/modules/highgui/src/loadsave.cpp, line 276
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/guillaume/Developpement/libs/OpenCV-2.2.0/modules/highgui/src/loadsave.cpp:276: error: (-2) could not find a writer for the specified extension in function imwrite_

Aborted (core dumped)

there is no error in compilation. It seems like an error in OpenCV version !?

edit retag flag offensive close merge delete

Comments

It would be better if you ask this question in StackOverflow, as I see that you are using a standalone OpenCV version. And by the way try updating your OpenCV first and retry, because your version is REALLY old. You could also try the cvSaveImage (old C implementation of imwrite) , docs on this link http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#imwrite

Mehdi. gravatar image Mehdi.  ( 2014-07-28 04:24:44 -0500 )edit
1

Instead of StackOverflow it would be even better to ask your question in http://answers.opencv.org

Martin Peris gravatar image Martin Peris  ( 2014-07-28 04:33:23 -0500 )edit

cvSaveImage is in C but I'm using C++ so it's imwrite. ya as I said maybe it's an old opencv version

ROSkinect gravatar image ROSkinect  ( 2014-07-28 04:46:02 -0500 )edit

3 Answers

Sort by » oldest newest most voted
0

answered 2014-07-29 03:45:13 -0500

ROSkinect gravatar image

The solutions that I found:

Either you change the OpenCV version to the latest one or use another library to save the image, example Visp:

#include <visp/vpImageConvert.h>
#include <visp/vpImageIo.h>

Mat image_mat;  
vpImageConvert::convert (image_mat, image_visp); //convert image_mat to image_visp
vpImageIo::write(image_visp,"*.jpg"); //save (you will find the image in /../../catkin_ws/*.jpg)
edit flag offensive delete link more
1

answered 2014-07-25 10:08:09 -0500

DevonW gravatar image

Sounds like it is unable to use *.jpg files. Try another format?

edit flag offensive delete link more

Comments

I tried all these extensions .pgm .jpg .png

ROSkinect gravatar image ROSkinect  ( 2014-07-28 04:05:50 -0500 )edit
1

answered 2014-07-28 20:17:07 -0500

What kind of image is cv_ptr->image? According to OpenCV 2.2 documentation:

Only 8-bit (or 16-bit in the case of PNG, JPEG 2000 and TIFF) single-channel or 3-channel (with ‘BGR’ channel order) images can be saved using this function.

Make sure that cv_ptr->image is an 8 bit single-channel or 3-channel image.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-07-25 09:02:00 -0500

Seen: 3,263 times

Last updated: Jul 29 '14