'Why does cv::imwrite is not working when I include the .png in the back?
I ran into this error message when I ran the following code:
char fileName[60];
//write new filname
sprintf(fileName,"/home/pi/Desktop/ML_TakeSample/DistanceMeasurement/image%i.png",i);
cout<<"saving "<< fileName <<endl;
//prep parameters for PNG file
vector<int> compression_params;
compression_params.push_back(IMWRITE_PNG_COMPRESSION);
compression_params.push_back(9);
//save to folder
imwrite(fileName, ToBeSaved[i], compression_params);
the error message:
error: (-2:Unspecified error) could not find a writer for the specified extension in function 'imwrite_'
When I look at others code that had the same error message, they didn't include .png or .jpg
Solution 1:[1]
Seems like the file direction got some problem, removed it and instead used "image%i.png" and it works now
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lol Skywalker |
