Skip to content

optflow(rlof): fix uninitialized variable #2728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions modules/optflow/src/rlof/berlof_invoker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ class TrackerInvoker : public cv::ParallelLoopBody
cv::Size _winSize = winSize;
float MEstimatorScale = 1;
int buffIdx = 0;
float c[8];
cv::Mat GMc0, GMc1, GMc2, GMc3;
cv::Vec2f Mc0, Mc1, Mc2, Mc3;
int noIteration = 0;
Expand Down Expand Up @@ -572,6 +571,7 @@ class TrackerInvoker : public cv::ParallelLoopBody
Mc3[0] = _b0[3];
Mc3[1] = _b1[3];

float c[8] = {};
c[0] = -Mc0[0];
c[1] = -Mc1[0];
c[2] = -Mc2[0];
Expand Down Expand Up @@ -830,7 +830,6 @@ class TrackerInvoker : public cv::ParallelLoopBody
int j;
float MEstimatorScale = 1;
int buffIdx = 0;
float c[8];
cv::Mat GMc0, GMc1, GMc2, GMc3;
cv::Vec4f Mc0, Mc1, Mc2, Mc3;
int noIteration = 0;
Expand Down Expand Up @@ -1355,6 +1354,7 @@ class TrackerInvoker : public cv::ParallelLoopBody
Mc3[3] = -_b3[3];

//
float c[8] = {};
c[0] = -Mc0[0];
c[1] = -Mc1[0];
c[2] = -Mc2[0];
Expand Down Expand Up @@ -1620,7 +1620,6 @@ class TrackerInvoker : public cv::ParallelLoopBody
nextPt += halfWin;
Point2f prevDelta(0,0);

float c[8];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main problem is here.
Scope of this variable is unclear. See code near line 1800:

                if(hasSolved == false)
                {
                    delta = Point2f( c[0] * ab + c[1] * a + c[2] * b + c[3],
                                     c[4] * ab + c[5] * a + c[6] * b + c[7]);

/cc @tsenst

for( j = 0; j < criteria.maxCount; j++ )
{
cv::Point2f delta;
Expand All @@ -1629,6 +1628,7 @@ class TrackerInvoker : public cv::ParallelLoopBody
b = nextPt.y - cvFloor(nextPt.y);
float ab = a * b;

float c[8] = {};

if( (inextPt.x != cvFloor(nextPt.x) || inextPt.y != cvFloor(nextPt.y) || j == 0))
{
Expand Down Expand Up @@ -1996,7 +1996,6 @@ namespace radial {
cv::Point2f backUpGain = gainVec;
cv::Size _winSize = winSize;
int j;
float c[8];
cv::Mat GMc0, GMc1, GMc2, GMc3;
cv::Vec4f Mc0, Mc1, Mc2, Mc3;
int noIteration = 0;
Expand Down Expand Up @@ -2359,6 +2358,7 @@ namespace radial {
Mc3[3] = -_b3[3];

//
float c[8] = {};
c[0] = -Mc0[0];
c[1] = -Mc1[0];
c[2] = -Mc2[0];
Expand Down