Inconsistencies regarding >>operator on video feed
Hi I am fairly new to OpenCV and recently I encountered one really weird situation when I tested out cv::absdiff on a video feed (I want to compare the first frame of the video with each following frame).
VideoCapture capture("768x576.avi");
Mat first_frame;
Mat current_frame;
//Mat diff;
capture>>first_frame;
while( (char)keyboard != 'q' && (char)keyboard != 27 ){
capture >> current_frame;
//cv::absdiff(current_frame, first_frame, diff);
imshow("first_frame", first_frame);
imshow("current_frame", current_frame);
keyboard = waitKey( 30 );
}
The weird thing I encountered is, you can see I only modified Mat first_frame once (putting in the first frame which isn't a black frame) but when I imshow both first_frame and current_frame on the while loop, they both "play" like a normal video which is weird since I do not modified first_frame in the while loop. Can anyone please explain why is this happening?
P/S: I solved it by cloning the first_frame into another Mat by still, why is this happening?