Kinect からの一連の深度フレームを格納する、およそ 11.1G のバイナリ ファイルがあります。このファイルには 19437 フレームがあります。1 回に 1 フレームを読み取るには、fstream で ifstream を使用しますが、ファイルの実際の末尾より前にeofに達します。(最初の 20 フレームしか取得できず、eofフラグのために関数が停止します)
ただし、代わりにstdioでfreadを使用すると、すべてのフレームを読み取ることができます。
誰でもこの状況を説明できますか? 私の質問に貴重な時間を割いていただきありがとうございます。
ここに私の2つの機能があります:
// ifstream.read() - Does Not Work: the loop will stop after 20th frame because of the eof flag
ifstream depthStream("fileName.dat");
if(depthStream.is_open())
{
while(!depthStream.eof())
{
char* buffer = new char[640*480*2];
depthStream.read(buffer, 640*480*2);
// Store the buffer data in OpenCV Mat
delete[] buffer;
}
}
// fread() - Work: Get 19437 frames successfully
FILE* depthStream
depthStream = fopen("fileName.dat", "rb");
if(depthStream != NULL)
{
while(!feof(depthStream))
{
char* buffer = new char[640*480*2];
fread(buffer, 1, 640*480*2, depthStream);
// Store the buffer data in OpenCV Mat
delete[] buffer;
}
繰り返しますが、私の質問に貴重な時間を割いていただきありがとうございます