I have a little complicated problem. I'll try to explain what I've done. I have a big class, which has as class-members
Mat vidImg
vector<Mat*> *VideoBuffer;
unsigned int currentVideoFrame;
I also have a class method
void loadVideoInBuffer(int num)
{
VideoBuffer.clear();
currentVideoFrame = 0;
vidDev.open(ListVideos.at(num).absoluteFilePath().toStdString()); // open videofile
while(true)
{
if(vidDev.read(vidImg) == false) // read from file int vidImg object
break;
VideoBuffer.push_back(new Mat(vidImg)); // pushback into vector
}
ui->tbVideo->setEnabled(true);
}
In this I am loading some objects loaded from another file into the Videobuffer vector. If I try to load it again from this vector in another class-member which I am assigning here:
void grabAndProcessFrameVideo() // reload and show loaded inage
{
if(vidFlag == true)
{
vidImg = Mat(*(VideoBuffer[currentVideoFrame])); // load from vector
currentVideoFrame++; // inc index for vector
imshow("img",vidImg); // show reloaded object in another window
}
}
The Mat Object and imshow function are from the opencv lib but I think that this doesn't really matter. My problem is, that it just shows the last image. If I try to access the buffervector directly in the loading function in this way
void EAMViewer::loadVideoInBuffer(int num)
{
ui->tbVideo->setDisabled(true);
VideoBuffer.clear();
currentVideoFrame = 0;
if(vidDev.open(ListVideos.at(num).absoluteFilePath().toStdString()) == false)
{
newLineInText(tr("no Device found"));
return;
}
while(true)
{
if(vidDev.read(vidImg) == false)
break;
VideoBuffer.push_back(new Mat(vidImg));
imshow("img",Mat(*(VideoBuffer)[currentVideoFrame]));
waitKey(30);
currentVideoFrame++;
}
currentVideoFrame = 0;
ui->tbVideo->setEnabled(true);
}
Then it shows me it as wanted. So I think that the vector Pointer constellation is problematical if I stay in scope.
My questions are now: 1. Why the program don't crash while grabbing and processing? 2. and what can i do, that it prevent deleting?
Thanks in advance,
Inge