ですから、プログラミングの経験がある人なら誰にでも明らかなように思えるかもしれませんが、私にはそうではないこの質問について誰かが私を助けてくれることを願っています! 多くのことについて適切な用語を知らないため、下手な説明をお許しください。
基本的に、フレームグラバーカードがインストールされている古い(っぽい)コンピューター(Matrox Meteor II)を使用してプロジェクトを継承しました。私の基本的な目的は、ライブ ビデオをカメラからリアルタイムでキャプチャし、圧縮せずにコンピュータのハード ディスクに書き込むことです。カードのプログラミングは C で行われ、Matrox Imaging Library (MIL) と呼ばれるバンドルされたライブラリを使用します。
現在、すべての画像をビット配列として生で書き込み、imageJを使用してそれらを表示しています。ダブル バッファリングを使用する基本的なプログラムを作成したので、画像がバッファにキャプチャされてからテキスト ファイルに書き込まれ、次の画像が別のバッファにキャプチャされます。以下にコード スニペットを示します。すべての M プレフィックス コマンドは MIL ライブラリからのものです。ただし、私を助けるためにそれらを実際に理解する必要はありません。
私は次のものを使用します:
/* 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);
私の問題は、24 fps のフレーム レートで上記を実行したいということですが、画像をキャプチャしてハードディスクに書き込むプロセスが、それよりもわずかに遅い場合があることがわかりました (速度の低下には一貫性がありませんが、プログラムはときどき 1 つのフレームに ~500 ミリ秒かかることがあります)。
これらの速度低下の原因を診断する方法を誰かが知っているかどうか、そしてそれが私のハードディスクの書き込み速度であるかどうか疑問に思っていました.