1 | initial version |
"only one image is recorded"
the problem is here:
sprintf(file,"%d%d%d_%d%d%d.pgm\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
it has a minimum resolution of 1 second, so all images taken in that timespan get saved under the same name.
so, either
add the clock() time:
sprintf(file,"%d%d%d_%d%d%d_%d.pgm\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, clock() );
or maybe a counter:
// somwhere out of the loop
int counter = 0;
// in the loop:
sprintf(file,"%d%d%d_%d%d%d.pgm\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, counter);
counter++;