Reputation: 427
I do have a function that I have created with a pointer as an argument. That argument will be used to save at the end an image. Every time when I would like to call that function with the desired parameter, I want that the saved image file would be with the specified name. I show you how:
void SaveImage(IplImage *img)
{
...
cvSaveImage("C:/img.png", img);
...
}
when calling the function: SaveImage(image1), I want to have an image on my C:/ whose name is image.png
Can you help me with that?
Upvotes: 0
Views: 108
Reputation: 129364
Apparently, you can't answer this question with the only answer that is actually viable, because you get downvoted...
So, I'll rephrase my answer:
You need to pass two variables to SaveImage:
void SaveImage(const char *name, IplImage *img)
{
...
cvSameImage(name, img);
}
Then your calling code will have to produce the correct name, such as:
SaveImage("c:\image.png", image);
SaveImage("c:\other.png", other);
Now, of course, if all you actually want is a unique name, rather than one that reflects the name of the variable in your code, then there are plenty of other possibilities, such as using a formatted string that contains a serial number, a random number, tmpnam()
or other similar schemes.
Upvotes: 2