The following command causes an exception.
cv::imwrite("test.jpg", diffImg);
I also tried numerous variations on this, including absolute paths and PNG export. Here's the error:
Exception at 0x75abd36f, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) in opencv_core231!cv::error
C:\slave\WinInstallerMegaPack\src\opencv\modules\highgui\src\loadsave.cpp:276: error: (-2) could not find a writer for the specified extension
According to this related thread my current OpenCV installation doesn't support the image formats I tried. But I merely downloaded the precompiled Windows framework like their site suggested.
How can I get JPG export working?
I have also faced this issue and I have observed that this issue will come when I use the image without any extension. like abc.jpg
but I rename it abc
only.
You must use an image name with extension.
Just mention the format in which you like to save your image like image.jpg, image.jpeg
cv2.imwrite('image.jpg',image)
it sounds as if you were using a different execution environment than the one you are compiling. Can you try the following? Download dependency walker and go to the executable directory and drag and drop the .exe file over dependency walker (http://www.dependencywalker.com/). It will show you which runtime libraries it is using. Now, make sure you are calling the program with the right environment. If you can, use a command line interface to call the program, it will make you feel safer to know where the code is being called from, so you can be sure your copied .dlls are being called.
Kind regards, Daniel
You need to recompile OpenCV and add support to "jpeg" format. Get the lastest opencv code and run cmake:
svn co http://code.opencv.org/svn/opencv/trunk/opencv myopencvdir.svn/
cd myopencvdir.svn/
mkdir release
cd release/
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
And check if libjpeg, libpng, libtiff are supported. If not you need to install them and re-run cmake.
Example of cmake output that shows Media I/O support:
-- Media I/O:
-- ZLib: TRUE
-- JPEG: TRUE
-- PNG: TRUE
-- TIFF: TRUE
-- JPEG 2000: TRUE
-- OpenEXR: YES
Before trying anything else, be sure you are setting up OpenCV and the VS project according to this answer, and be carefully not to mix OpenCV release libraries with the debug libraries.
There are a couple of things you might try:
If you are on Windows 7 64 bits, you might want to follow this or this instructions.
I noticed a similar question on javacv wiki and this is another possible solution:
Head over to this page, follow the instructions to setup opencv 2.3.1 till Step 2. (Use 32-bit mode)
Download the latest version of TBB for Windows from here.
Extract the TBB zip file and copy all .dll files inside / bin / ia32 / vc10 and all .dll files in / bin / ia32 / vc10 / irml into your C:\ OpenCV 2.3.1\ build\ x86\ vc10\ bin
Let us know how you did.
I run into the same runtime error "opencv error unspecified error (could not find a writer for the specified extension)". I used the same solution as Pieter, that is in the project setting-->linker-->Input-->Aditional Dependencies, I specified to use the debug version of the opencv libs for MSVS debug cofiguration, and specify to use the release version of the opencv libs for MSVS release configuration. Then the runtime error is gone.
Yes,it works for me.
For debug just remove thoes *.lib left *d.lib (Property Pages/Linker/Input/Additional Dependencies)
, just copy these *d.lib
:
User contributions licensed under CC BY-SA 3.0