Hi,
I would like to use my webcam as a photo camera.
I would like to have a function like "Mat GetOneFrame();" which I can call in short distances to deliver just one up to date frame.
How can I do this?
I normally use my camera like this:
#include "opencv2/opencv.hpp"
using namespace cv;
int main(int, char**)
{
VideoCapture cap(0);
if(!cap.isOpened())
return -1;
namedWindow("video",1);
for(;;)
{
Mat frame;
cap >> frame;
imshow("video", frame);
if(waitKey(30) >= 0) break;
}
return 0;
}
I have tried to delete the for loop and then to use "cap>>fame" whenever I need it. But if I try this, my programm freezes even if I wait a second before trying to get a new frame.
What can I do? Thank you very much :-)