Hi,
I am trying to run gpu::BroxOpticalFlow on some images. I get an assertion error:
OpenCV Error: Assertion failed (_rows >= 0 && _cols >= 0) in unknown function, file ..\..\opencv-2.4\modules\core\src\gpumat.cpp, line 1525
Here's my code snippet:
int main()
{
cv::Mat img1;
cv::Mat img2;
img1 = imread("1.png", CV_LOAD_IMAGE_GRAYSCALE);
img2 = imread("2.png", CV_LOAD_IMAGE_GRAYSCALE);
namedWindow( "window1", CV_WINDOW_AUTOSIZE );
imshow( "window1", img1 );
namedWindow( "window2", CV_WINDOW_AUTOSIZE );
imshow( "window2", img2 );
img1.convertTo(img1, CV_32FC1);
img2.convertTo(img2, CV_32FC1);
cv::gpu::GpuMat img1gpu(img1);
cv::gpu::GpuMat img2gpu(img2);
cv::gpu::GpuMat FlowXGPU;
cv::gpu::GpuMat FlowYGPU;
cv::gpu::BroxOpticalFlow OpticalFlowGPU = cv::gpu::BroxOpticalFlow(0.197f, 0.8f, 50.0f, 10, 77, 10);
OpticalFlowGPU(img1gpu, img2gpu, FlowXGPU, FlowYGPU);
cv::Mat FlowX;
cv::Mat FlowY;
FlowXGPU.download(FlowX);
FlowYGPU.download(FlowY);
waitKey(0);
}
The usage of the Brox function is the same as in a post here: http://stackoverflow.com/questions/15069255/opencv-brox-optical-flow-exception-in-opencv-core244dcvglbufferunbind. I just wanted to see if it works.
I'm pretty sure this has to do with the sizes of FlowXGPU and FlowYGPU... I'm very new to OpenCV and would really appreciate some advice.
Thank you.