Ask Your Question

Revision history [back]

Accumulating a number of Mat in vector<mat>

I'm grabbing frame from webcam am displaying them on a window. To do a temporal analysis, I keeping the frames on a vector<mat> as I grab them. In order to test it, when the size of my vector reaches 100, I attempt to visualize all the frames that I stored so far. The strange thing is that, indeed the vector has 100 frames inside, but they are all the same and correspond to the last frame that was captured.

Code:

Mat frame;       

    _cap.start(0);  //VideoCapture object   

    vector<Mat> seq;
    while(1)
    {
        _cap.getFrame(frame);           

        seq.push_back(frame);

        imshow("a", seq[0]);

        if (seq.size() == 100)
        {
            for (int n = 0; n < seq.size(); n++)
            {
                cout << "entrei" << endl;
                imshow("b", seq[n]);
                waitKey(0);
            }
        }    
    }

Accumulating a number of Mat in vector<mat>

I'm grabbing frame from webcam am displaying them on a window. To do a temporal analysis, I keeping the frames on a vector<mat> as I grab them. In order to test it, when the size of my vector reaches 100, I attempt to visualize all the frames that I stored so far. The strange thing is that, indeed the vector has 100 frames inside, but they are all the same and correspond to the last frame that was captured.

Code:

Mat frame;       

    _cap.start(0);  //VideoCapture object   

    vector<Mat> seq;
    while(1)
    {
        _cap.getFrame(frame);           

        seq.push_back(frame);

        imshow("a", seq[0]);

        if (seq.size() == 100)
        {
            for (int n = 0; n < seq.size(); n++)
            {
                cout << "entrei" "I'm in" << endl;
                imshow("b", seq[n]);
                waitKey(0);
            }
        }  }

            waitKey(30);   
    }