How to use a camera to get single frames?
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.
This is my try:
void TakeOneFrame()
{
namedWindow("Video");
namedWindow("Picture");
Mat frame;
Mat picture;
VideoCapture cap (0);
for(int i=0; i<=2;i++)
{
if(char(waitKey(1)) != 'q' &&cap.isOpened())
{cap.operator >>(frame);}
frame.copyTo(picture);
imshow("Video", frame);
}
cap.release();
while(1)
{
imshow("Picture",picture);
}
}
I found out, that I need to grab a few frames until there is one sharp one. The Video window produces the desired frame, but when the window "Picture" opens up, there is no image showing. Even if I chance the position of frame.copyTo(picture); this makes no change.
Why is that and is there a better solution for my problem?
Thank you very much :-)