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

This commit is contained in:
Vladislav Vinogradov 2012-03-07 13:41:49 +00:00
parent 1a25e58239
commit 855feedda7

View File

@ -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
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
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? u(y, x) = nextPt.x - x + c_halfWin_x;
nextPt.x += c_halfWin_x; v(y, x) = nextPt.y - y + c_halfWin_y;
nextPt.y += c_halfWin_y;
u(y, x) = nextPt.x - x;
v(y, x) = nextPt.y - y;
if (calcErr && !GET_MIN_EIGENVALS) if (calcErr && !GET_MIN_EIGENVALS)
{ {