I'm trying to double buffer my VideoCapture output in my OpenCV program (to reduce flicker). Here's the concept so far:
Mat frameA, frameB; //alternating between these two for storage
VideoCapture cap(0); // open the default camera
for(;;)
{
cap >> frameB;
waitKey(30);
cap >> frameA;
waitKey(30);
putText(frameA,SSTR("A"),Point(frameA.cols/2,frameA.rows/2),3,5,CV_RGB(250,200,200));
putText(frameB,SSTR("B"),Point(frameA.cols/2,frameB.rows/2),3,5,CV_RGB(250,200,200));
imshow("A",frameA);
imshow("B",frameB);
waitKey(30);
}
as a simple test I write the text A or B in the center of the frame. But the output has A and B overlapping - as if there were not two separate frames. What am I doing wrong?
I have made a solution by using the .clone() operator, but I understand that that sort of thing is horribly expensive in terms of CPU (?) and so would like to avoid it. Hopefully we've got some C++ double buffering experts here.