Try to explicitly specify the extension:
sprintf(file,"Image %d.jpg",cnt);
imwrite(file,image);
题
I am writing a ROS node in which i subsribe to images from another node. I use cv_bridge to use imshow and display the image. I want to save the image to disk. I used imwrite and can save it. But when the other node publishes another image, its over-writing to the same file. I want to save the image to a different file each time an image comes.
This is how i tried :-
char file[10];
cnt++; //each time an image comes increment cnt
sprintf(file,"Image %d",cnt); //different filename so it doesnt overwrite
imwrite(file,image);
I got error like this :-
Any suggestions?
解决方案
Try to explicitly specify the extension:
sprintf(file,"Image %d.jpg",cnt);
imwrite(file,image);