Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using gpu::BroxOpticalFlow, assertion failed


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;;;


The usage of the Brox function is the same as in a post here: 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.