Question

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 :-

error msg

Any suggestions?

Was it helpful?

Solution

Try to explicitly specify the extension:

sprintf(file,"Image %d.jpg",cnt);       
imwrite(file,image);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top