I'm new to opencv and it's developing. I opened camera feed and i want to take the last frame after the 30s. and save the frame in Mat type object. to ensure that i used imshow to display the used image. but i got errors please find below the code i used.
int main(int argc, char** argv){
VideoCapture cap(0);
vector<Mat> frame;
namedWindow("feed",1);
for(;;)
{
frame.push_back(Mat()); // push back images of Mat type
cap >> frame.back(); // take the last frame
imshow("feed", frame);
if (waitKey(30) >=0) { // wait 30s to take the last
break;
}
}
return(0);
Error
OpenCV Error: Assertion failed (0 <= i && i < (int)v.size()) in getMat, file /Users/waruni/Documents/opencv/modules/core/src/matrix.cpp, line 992
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/waruni/Documents/opencv/modules/core/src/matrix.cpp:992: error: (-215) 0 <= i && i < (int)v.size() in function getMat
imshow("feed", frame.back());
(you can#t use imshow() with a whole vector – berak