So I hope someone can help me with this question which might seem obvious to anyone with any amount of programming experience but not to me! Please excuse my poor descriptions since I don't know the right terminology for a lot of things.
Basically I've inherited a project using an old(ish) computer which has a framegrabber card installed (Matrox Meteor II). My basic aim is to simply capture live video in real time from a camera and write it uncompressed to the hard disk of the computer. Programming for the card is done in C and makes use of a library which came bundled with it called the Matrox Imaging Library (MIL).
Currently I am just writing all my images in raw as a bit array and using imageJ to view them. I've written a basic program which uses double buffering, so an image is captured to a buffer then written to the text file while the next image is captured to another buffer. I will put a code snippet below, all of the M-prefix commands are from the MIL library. You don't actually need to understand them to help me, however.
I just use the following:
/* Put the digitizer in asynchronous mode. */
MdigControl(MilDigitizer, M_GRAB_MODE, M_ASYNCHRONOUS);
/* Grab the first buffer. */
MdigGrab(MilDigitizer, MilImage[0]);
/*open my file where I will write the images*/
pfile = fopen("myfile.txt", "wb");
/* Process one buffer while grabbing the other. */
while( !kbhit() )
{
/* Grab second buffer while processing first buffer. */
MdigGrab(MilDigitizer, MilImage[1]);
/* Synchronize and start the timer. */
if (NbProc == 0)
{
MappTimer(M_TIMER_RESET, M_NULL);
}
/* Process the first buffer already grabbed. */
/*copy the image to a display buffer*/
#if COPY_IMAGE
MbufCopy(MilImage[0], MilImageDisp);
#endif
/*Here we copy the buffer into a user supplied array*/
MbufGet(MilImage[0], my_array);
/* Then we write the array into the text file using fwrite*/
fwrite(my_array,sizeof(char),sizeof(my_array),pfile);
/*Output the amount of time it took to process that image*/
MappTimer(M_TIMER_READ, &Time);
Capture_Time = Time - Time_Holder;
printf("IMG %s took %.7f .\n", text, Capture_Time);
Time_Holder = Time;
/* Count processed buffers. */
NbProc++;
/* Grab first buffer while processing second buffer. */
MdigGrab(MilDigitizer, MilImage[0]);
/* Process the second buffer already grabbed. */
#if COPY_IMAGE
MbufCopy(MilImage[1], MilImageDisp);
#endif
/*Here we copy the buffer into our array*/
MbufGet(MilImage[1], my_array);
/* Then we write the array into the text file using fwrite*/
fwrite(my_array,sizeof(char),sizeof(my_array),pfile);
MappTimer(M_TIMER_READ, &Time);
Capture_Time = Time - Time_Holder;
printf("IMG %s took %.7f .\n", text, Capture_Time);
Time_Holder = Time;
/* Count processed buffers. */
NbProc++;
}
getchar();
/* Wait last grab end and stop timer. */
MdigGrabWait(MilDigitizer, M_GRAB_END);
/*Close our file*/
fclose(pfile);
My problem is that I would like to be doing the above at a frame rate of 24fps, but I find that the process of capturing images and writing them to the hard disk is slightly slower than that sometimes (the slowdown is inconsistent but the program seems to occasionally hang on one frame for ~500ms).
I was wondering if anyone knew of a way to diagnose what causes these slowdowns, and whether it might be the write speed of my hard disk.