1

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?

Karthik Murugan
  • 1,595
  • 4
  • 19
  • 26

1 Answers1

3

Try to explicitly specify the extension:

sprintf(file,"Image %d.jpg",cnt);       
imwrite(file,image);
Ann Orlova
  • 1,338
  • 15
  • 24