Reputation: 1795
I have spent half day to find the error. Finally I found this strange thing:
In one part of my code method1 I do the following:
Mat prevgray, gray, flow, cflow, frame;
cvtColor(frame1, prevgray, CV_BGR2GRAY);
cvtColor(frame2, gray, CV_BGR2GRAY);
calcOpticalFlowFarneback(prevgray, gray, flow, 0.5, 3, 15, 3, 5, 1.2, 0);
...
In other part, method2, I create new Mat and try to display it :
Mat result(480,640, CV_8UC3);
result.at<cv::Vec3b>(y,x)[0] = b;
result.at<cv::Vec3b>(y,x)[1] = g;
result.at<cv::Vec3b>(y,x)[2] = r;
namedWindow( "jojw", CV_WINDOW_AUTOSIZE );
imshow("jojw",result);
waitKey(0);
The result is this image:
However, if I don't use calcOpticalFlowFarneback method. I comment out it or return before code reaches it. The result image is OK.
What's happening?
Please help me
Upvotes: 2
Views: 1740
Reputation: 1795
Solved myself. 12 hours spent to get this stupid error. Is that error? I still don't understand but the solution is to create zeros mat:
Mat result = Mat::zeros(480,640, CV_8UC3);
Upvotes: 1