Reputation: 11
I was trying to write an image to a folder using OpenCV imwrite function. The code compiles and runs successfully but the image is not saving in the folder/path.I am getting output from 'imshow' and my image is in CV_8UC1 format.
find the code below
Mat reflection = function which computes image
imshow("output image", reflection);
imwrite("E:/New folder/img.bmp", reflection);
so I checked current folder writing and modified code like this
bool check = imwrite("./img.bmp", reflection);
this 'bool check' status is 'false' and not writing the image.
I've also checked folder permission with guidelines from microsoft help my "E/New Folder/" is permitted to write. still, the image is not saving. I am okay with any image format .jpg, .png and .bmp. I am using windows 7, OpenCV 3.0, visual studio 2017.
Please help me and thanks for reading it
Upvotes: 0
Views: 7880
Reputation: 1
OpenCV do support bmp, just use as follows.
bool check = imwrite("img.bmp", reflection);
Upvotes: 0
Reputation: 86
Opencv doesn't seem to support saving BMP files check the imwrite docs. Changing the filename to img.png
should work. Also using ./
in windows is not valid, this is used in unix systems to represent the current working directory see Windows current directory.
Updating it to
bool check = imwrite(".\img.png", reflection);
or
bool check = imwrite("img.png", reflection);
Should work
Upvotes: 2