filename problem with imwrite() function
Hello guys, I have a small problem with imwrite(). I am processing each frame of a video. And I wish to store the frame once I press S key. Here is my code for generating the string of fileName. But I can't save the image.
char c = waitKey(1000 / 1);
if (c == 's') {
ostringstream out;
out << "img" << cap.get(CAP_PROP_POS_FRAMES) << ".jpg" << endl;
string fileName(out.str());
cout << fileName << endl;
imwrite(fileName, diffFrame);
}
But if I directly replace imwrite() with imwrite("img1.jpg", diffFrame), it works. I don't know why it happens. Is there anyone who knows? Thanks you.
what is the exact problem ? `
i can't
is not precise enough.did you check, what
cap.get(CAP_PROP_POS_FRAMES)
returns ? (is it supported for your device ?)remove endl in out << "img" << cap.get(CAP_PROP_POS_FRAMES) << ".jpg" << endl;
jpg\n is not a valid extension file : nothing is saved
Oh, yes. I haven't noticed that endl. Thank you!!