Commit 855feedd authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

fixed error calculation in gpu::PyrLKOpticalFlow (Bug #1651)

parent 1a25e582
...@@ -445,20 +445,12 @@ namespace cv { namespace gpu { namespace device ...@@ -445,20 +445,12 @@ namespace cv { namespace gpu { namespace device
nextPt.y += delta.y; nextPt.y += delta.y;
if (::fabs(delta.x) < 0.01f && ::fabs(delta.y) < 0.01f) if (::fabs(delta.x) < 0.01f && ::fabs(delta.y) < 0.01f)
{
nextPt.x -= delta.x * 0.5f;
nextPt.y -= delta.y * 0.5f;
break; break;
}
} }
if (nextPt.x < -c_winSize_x || nextPt.x >= cols || nextPt.y < -c_winSize_y || nextPt.y >= rows) if (nextPt.x < -c_winSize_x || nextPt.x >= cols || nextPt.y < -c_winSize_y || nextPt.y >= rows)
status_ = false; status_ = false;
// TODO : Why do we compute patch error in shifted window?
nextPt.x += c_halfWin_x;
nextPt.y += c_halfWin_y;
float errval = 0.f; float errval = 0.f;
if (calcErr && !GET_MIN_EIGENVALS && status_) if (calcErr && !GET_MIN_EIGENVALS && status_)
{ {
...@@ -478,6 +470,9 @@ namespace cv { namespace gpu { namespace device ...@@ -478,6 +470,9 @@ namespace cv { namespace gpu { namespace device
if (tid == 0) if (tid == 0)
{ {
nextPt.x += c_halfWin_x;
nextPt.y += c_halfWin_y;
status[blockIdx.x] = status_; status[blockIdx.x] = status_;
nextPts[blockIdx.x] = nextPt; nextPts[blockIdx.x] = nextPt;
...@@ -633,14 +628,10 @@ namespace cv { namespace gpu { namespace device ...@@ -633,14 +628,10 @@ namespace cv { namespace gpu { namespace device
if (::fabs(delta.x) < 0.01f && ::fabs(delta.y) < 0.01f) if (::fabs(delta.x) < 0.01f && ::fabs(delta.y) < 0.01f)
break; break;
} }
// TODO : Why do we compute patch error in shifted window?
nextPt.x += c_halfWin_x;
nextPt.y += c_halfWin_y;
u(y, x) = nextPt.x - x; u(y, x) = nextPt.x - x + c_halfWin_x;
v(y, x) = nextPt.y - y; v(y, x) = nextPt.y - y + c_halfWin_y;
if (calcErr && !GET_MIN_EIGENVALS) if (calcErr && !GET_MIN_EIGENVALS)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment