remove unused function from pyrlk_optical_flow sample
This commit is contained in:
@@ -77,44 +77,6 @@ template <typename T> inline T mapValue(T x, T a, T b, T c, T d)
|
|||||||
return c + (d - c) * (x - a) / (b - a);
|
return c + (d - c) * (x - a) / (b - a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getFlowField(const Mat& u, const Mat& v, Mat& flowField)
|
|
||||||
{
|
|
||||||
float maxDisplacement = 1.0f;
|
|
||||||
|
|
||||||
for (int i = 0; i < u.rows; ++i)
|
|
||||||
{
|
|
||||||
const float* ptr_u = u.ptr<float>(i);
|
|
||||||
const float* ptr_v = v.ptr<float>(i);
|
|
||||||
|
|
||||||
for (int j = 0; j < u.cols; ++j)
|
|
||||||
{
|
|
||||||
float d = max(fabsf(ptr_u[j]), fabsf(ptr_v[j]));
|
|
||||||
|
|
||||||
if (d > maxDisplacement)
|
|
||||||
maxDisplacement = d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flowField.create(u.size(), CV_8UC4);
|
|
||||||
|
|
||||||
for (int i = 0; i < flowField.rows; ++i)
|
|
||||||
{
|
|
||||||
const float* ptr_u = u.ptr<float>(i);
|
|
||||||
const float* ptr_v = v.ptr<float>(i);
|
|
||||||
|
|
||||||
|
|
||||||
Vec4b* row = flowField.ptr<Vec4b>(i);
|
|
||||||
|
|
||||||
for (int j = 0; j < flowField.cols; ++j)
|
|
||||||
{
|
|
||||||
row[j][0] = 0;
|
|
||||||
row[j][1] = static_cast<unsigned char> (mapValue (-ptr_v[j], -maxDisplacement, maxDisplacement, 0.0f, 255.0f));
|
|
||||||
row[j][2] = static_cast<unsigned char> (mapValue ( ptr_u[j], -maxDisplacement, maxDisplacement, 0.0f, 255.0f));
|
|
||||||
row[j][3] = 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[])
|
int main(int argc, const char* argv[])
|
||||||
{
|
{
|
||||||
const char* keys =
|
const char* keys =
|
||||||
|
|||||||
Reference in New Issue
Block a user