I am composing a video from a sequence of images obtained by glob. I am getting many messages for output starting in: INFO[0]. I could not find in internet a specific reason for such message. Could someone help me to see where is the error? The code builds perfectly:
I don’t know about that error message, but VideoWriter::write() is supposed to take one image as argument, so you’d need to loop though your images. The same applies to imshow. Also, you may want to to check the actual size of your images.
for (size_t p = 0; p < count_BG; p++) {
BG_images.push_back(imread(f_BG[p], IMREAD_GRAYSCALE));
}
VideoWriter writer;
int codec = VideoWriter::fourcc('H', 'F', 'Y', 'U');
double fps = 4;
std::string filename = "vid.avi";
int p=0;
writer.open(filename, codec, fps, BG_images[p].size(), false);
for (int p = 0; p < count_BG; p++)
{
writer.write(BG_images[p]);
}
writer.release();
return 0;
}
Observation: I shoul put inside the loop as Matti sayed, I should change to use de HFYU codec for better video resolution and I should change my IMREAD to GRAYSCALE instead UNCHANGED or ANYDEPTH because the images that I am using with are PNG 16 bit.
The INFO 0 messages still remain appearing in output, example:
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\videoio_registry.cpp (197) cv::`anonymous-namespace’::VideoBackendRegistry::VideoBackendRegistry VIDEOIO: Enabled backends(8, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930)
[ INFO:0] global C:\build\master_winpack-build-win6
I found a problem… the images are being stored in the following sequence:
0
1
11
12
.
.
.
19
2
21
22
what is changing the order of some frames. I guess that is due the string to be a vector, I am trying to fix it but I am not obtaining success.
that is due to the glob. the glob seems to give you a sorted list of files.
you can either name your files with leading zeros, which makes lexical order and numerical order identical… or you can run a loop through the numbers, generate the file name, and load each file from that (without the glob).
Thank you! Now it is working perfect.
I did not know about this “trick” of leading zero. That help me to understand better the difference of glob and loop.