cvCalcOpticalFlow throws an error is status parameter is NULL (Bugfix #2526)
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
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