cvCalcOpticalFlow throws an error is status parameter is NULL (Bugfix #2526)


Added by Jack Valmadre over 12 years ago. Updated about 12 years ago.


Status:Done Start date:2012-11-09
Priority:Normal Due date:
Assignee:Andrey Kamaev % Done:

50%

Category:imgproc, video
Target version:2.4.4 Estimated time:1.00 hour
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

If I call cvCalcOpticalFlow with the status parameter set to zero, I get the following error:

OpenCV Error: Null pointer (create() called for the missing output array) in create, file /Users/jack/src/OpenCV-2.4.1/modules/core/src/matrix.cpp, line 1461

I was able to fix this by changing this line: (in modules/video/src/lkpyramid.cpp)

    cv::calcOpticalFlowPyrLK( A, B, ptA, ptB, status ? cv::_OutputArray(st) : cv::_OutputArray(),
                              error ? cv::_OutputArray(err) : cv::_OutputArray(),
                              winSize, level, criteria, flags);

to this:

    cv::calcOpticalFlowPyrLK( A, B, ptA, ptB, cv::_OutputArray(st),
                              error ? cv::_OutputArray(err) : cv::_OutputArray(),
                              winSize, level, criteria, flags);

so that it uses the cv::Mat st which exists only in this scope if none is provided.

I don't have any experience using _OutputArray directly, so I'm not sure if this is the best way to do it.

It might be worth doing the same thing for the error parameter, I figured I'd change as little as possible.

This fixes a bug in the OpenTLD project:
https://github.com/zk00006/OpenTLD/issues/22

I'm using OpenCV 2.4.1 on Mac OS X.


Associated revisions

Revision c6199fc3
Added by Andrey Pavlenko almost 11 years ago

Merge pull request #2526 from KonstantinMatskevich:ocl_morph_fix

History

Updated by Jack Valmadre over 12 years ago

ugh.. if** status parameter is null

Updated by Kirill Kornyakov over 12 years ago

  • Target version changed from 3.0 to 2.4.4
  • Tracker changed from Patch to Bugfix

Updated by Andrey Kamaev about 12 years ago

Fix is pushed to 2.4 - 5e2726fb

  • Assignee changed from Vadim Pisarevsky to Andrey Kamaev
  • Status changed from Open to Done

Also available in: Atom PDF