Reputation: 811
in the standard grabcut program that comes in the samples of opencv, I added a few lines of code to save the result to a file. However, nothing is there in the file. Just a black solid color. Here's the code that I put in --
in the main function
case 's':
gcapp.writeToFile(writefilename);
break;
in the GCApplication class
void writeToFile(string filename)
{
imwrite(filename, mask);
cout << "file written" << endl;
}
I'm assuming that you know the grabcut program and you have the code to look at it. Please let me know if I need to post more info... thanks!
Upvotes: 0
Views: 462
Reputation: 93410
You are saving the wrong cv::Mat
. The one that is displayed at the end of showImage()
is res
, which is a local variable. You should make it a class variable, and then the method writeToFile()
should execute:
imwrite(filename, res);
Upvotes: 1