Following is my code. It has an array of Mat type objects. And I add the Mat made inside the for loop as imgArr[index] = img. But when I output all the frames to see the animation on the window, it just shows the last frame and shows the same frame.
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
int numFrames = endFrame - startFrame; // Total number of frames
Mat imgArr[100];
for(long int FrameNumber = startFrame; FrameNumber < endFrame; FrameNumber++){
fp.seekg( BytesPerFrame*(FrameNumber), std::ios::beg);
char buffer[BytesPerImage];
fp.read(buffer, BytesPerImage);
short image[512*512];
short min = 20000, max=1000;
for ( int i = 0; i < BytesPerImage; i=i+2 )
{
int a;
a = floor(i/2)+1;
// take first character
image[a] = (static_cast<unsigned int>(static_cast<unsigned char>(buffer[i+1]))*256+static_cast<unsigned int>(static_cast<unsigned char>(buffer[i])));
if(image[a] < min){
min = image[a];
}
if(image[a] > max){
max = image[a];
}
}
// Processing the image
Mat img(512, 512, CV_16S, image);
img -= (min);
img *= (32767/max); // (330000/2500);
img *= ((max/min)/2) + 2; // 16;
imgArr[FrameNumber-startFrame] = img;
}
for(int i = 0; i<numFrames; i++){
imshow( "Display window", imgArr[i]); // Show our image inside it.
waitKey(50);
}
Aucun commentaire:
Enregistrer un commentaire