I have a code
VideoCapture cap("test.mp4");
if(!cap.isOpened()){
cout << "Error opening video stream or file" << endl;
return -1;
}
while(1){
Mat frame;
// Capture frame-by-frame
cap >> frame;
// If the frame is empty, break immediately
if (frame.empty())
break;
// Display the resulting frame
imshow( "Fr", test(frame ));
// Press ESC on keyboard to exit
char c = (char)waitKey(1);
if( c == 27 )
break;
}
cap.release();
and function test()
Mat test(Mat frame){
for(int i = 0; i < frame.rows; i++){
for(int j = 0; j < frame.cols; j++){
frame.at<uchar>(i,j) = 250;
}
}
return frame;
}
I expected that this function will return a transformed frame, totally white. But instead, it returns me a frame where 1/3 of columns white:
if I transform code above
for(int j = 0; j < 2*frame.cols; j++){
instead of
for(int j = 0; j < frame.cols; j++){
I got this:
and if I change code like this:
for(int j = 0; j < 3*frame.cols; j++){
I eventually got that I expected, white frame.
Why it works so weird? I have a loop on all rows and columns and yet I don't get totally white picture. If I use this function test() on usual picture, it returns white Mat. But with frame of VideoCapture result is different. Why?