Merge pull request #6769 from andy-held:cuda_optflow_error_calc
This commit is contained in:
commit
9bda0546f8
@ -344,6 +344,18 @@ namespace pyrlk
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct DenormalizationFactor
|
||||||
|
{
|
||||||
|
static const float factor = 1.0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct DenormalizationFactor<uchar>
|
||||||
|
{
|
||||||
|
static const float factor = 255.0;
|
||||||
|
};
|
||||||
|
|
||||||
template <int cn, int PATCH_X, int PATCH_Y, bool calcErr, typename T>
|
template <int cn, int PATCH_X, int PATCH_Y, bool calcErr, typename T>
|
||||||
__global__ void sparseKernel(const float2* prevPts, float2* nextPts, uchar* status, float* err, const int level, const int rows, const int cols)
|
__global__ void sparseKernel(const float2* prevPts, float2* nextPts, uchar* status, float* err, const int level, const int rows, const int cols)
|
||||||
{
|
{
|
||||||
@ -532,7 +544,7 @@ namespace pyrlk
|
|||||||
nextPts[blockIdx.x] = nextPt;
|
nextPts[blockIdx.x] = nextPt;
|
||||||
|
|
||||||
if (calcErr)
|
if (calcErr)
|
||||||
err[blockIdx.x] = static_cast<float>(errval) / (cn * c_winSize_x * c_winSize_y);
|
err[blockIdx.x] = static_cast<float>(errval) / (::min(cn, 3) * c_winSize_x * c_winSize_y) * DenormalizationFactor<T>::factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,7 +737,7 @@ namespace pyrlk
|
|||||||
nextPts[blockIdx.x] = nextPt;
|
nextPts[blockIdx.x] = nextPt;
|
||||||
|
|
||||||
if (calcErr)
|
if (calcErr)
|
||||||
err[blockIdx.x] = static_cast<float>(errval) / (3 * c_winSize_x * c_winSize_y);
|
err[blockIdx.x] = static_cast<float>(errval) / (::min(cn, 3)*c_winSize_x * c_winSize_y);
|
||||||
}
|
}
|
||||||
} // __global__ void sparseKernel_
|
} // __global__ void sparseKernel_
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user