I have this code to create and write an image in opencv:
char * outImage="C:/tmp/000014/outimage.jpg";
Mat gray_image(imageWidth,imageHeight, CV_8UC1, Scalar(255));
imwrite( outImage, gray_image );
but when I am running thid code, I am getting error that file extension is not known and hence iwrite can not write image.
What is wrong with this code?
edit1
I changed the code to see there is a problem with code or installation. so I have this code now
Mat x=imread("C:/tmp/a.jpg");
imshow("Image", x);
waitKey(0);
I am sure that the file c:/tmp/a.jpg exist.
When I run the application, I am getting this error:
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in unknown function, file C:\slave\builds\WinInstallerMegaPack\src\opencv\modules\core\src\array.cpp, line 2482
C:\slave\builds\WinInstallerMegaPack\src\opencv\modules\core\src\array.cpp:2482: error: (-206) Unrecognized or unsupported array type
I followed this answer in so to install OpenCV o my system (I use vc11, insteade of vc10 during installation) Installing OpenCV 2.4.3 in Visual C++ 2010 Express
edit 2
The problem was that I mixed the debug and release libraries,
For release use release libraries which don't have d at the end (for example opencv_calib3d243.lib instead od opencv_calib3d243d.lib)
for debug use debug libraries which has d at the end for example opencv_calib3d243d.lib
Make sure that you are using the correct lib name based on the opencv version that you have for example opencv_calib3d245d.lib for opencv 2.4.5.