changed nullptr to NULL to avoid c++11 (failed to build on linux)
replaces tabs with spaces
This commit is contained in:
parent
062e1cbe06
commit
eb6c598678
@ -211,13 +211,13 @@ public:
|
|||||||
* The method is stable for a large range of values of this parameter.
|
* The method is stable for a large range of values of this parameter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
double gamma;
|
double gamma;
|
||||||
/**
|
/**
|
||||||
* parameter used for motion estimation. It adds a variable allowing for illumination variations
|
* parameter used for motion estimation. It adds a variable allowing for illumination variations
|
||||||
* Set this parameter to 1. if you have varying illumination.
|
* Set this parameter to 1. if you have varying illumination.
|
||||||
* See: Chambolle et al, A First-Order Primal-Dual Algorithm for Convex Problems with Applications to Imaging
|
* See: Chambolle et al, A First-Order Primal-Dual Algorithm for Convex Problems with Applications to Imaging
|
||||||
* Journal of Mathematical imaging and vision, may 2011 Vol 40 issue 1, pp 120-145
|
* Journal of Mathematical imaging and vision, may 2011 Vol 40 issue 1, pp 120-145
|
||||||
*/
|
*/
|
||||||
double theta;
|
double theta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -254,8 +254,8 @@ private:
|
|||||||
std::vector<GpuMat> I0s;
|
std::vector<GpuMat> I0s;
|
||||||
std::vector<GpuMat> I1s;
|
std::vector<GpuMat> I1s;
|
||||||
std::vector<GpuMat> u1s;
|
std::vector<GpuMat> u1s;
|
||||||
std::vector<GpuMat> u2s;
|
std::vector<GpuMat> u2s;
|
||||||
std::vector<GpuMat> u3s;
|
std::vector<GpuMat> u3s;
|
||||||
|
|
||||||
GpuMat I1x_buf;
|
GpuMat I1x_buf;
|
||||||
GpuMat I1y_buf;
|
GpuMat I1y_buf;
|
||||||
@ -270,9 +270,9 @@ private:
|
|||||||
GpuMat p11_buf;
|
GpuMat p11_buf;
|
||||||
GpuMat p12_buf;
|
GpuMat p12_buf;
|
||||||
GpuMat p21_buf;
|
GpuMat p21_buf;
|
||||||
GpuMat p22_buf;
|
GpuMat p22_buf;
|
||||||
GpuMat p31_buf;
|
GpuMat p31_buf;
|
||||||
GpuMat p32_buf;
|
GpuMat p32_buf;
|
||||||
|
|
||||||
GpuMat diff_buf;
|
GpuMat diff_buf;
|
||||||
GpuMat norm_buf;
|
GpuMat norm_buf;
|
||||||
|
@ -64,7 +64,7 @@ cv::cuda::OpticalFlowDual_TVL1_CUDA::OpticalFlowDual_TVL1_CUDA()
|
|||||||
epsilon = 0.01;
|
epsilon = 0.01;
|
||||||
iterations = 300;
|
iterations = 300;
|
||||||
scaleStep = 0.8;
|
scaleStep = 0.8;
|
||||||
gamma = 0.0;
|
gamma = 0.0;
|
||||||
useInitialFlow = false;
|
useInitialFlow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::operator ()(const GpuMat& I0, const Gp
|
|||||||
I1s.resize(nscales);
|
I1s.resize(nscales);
|
||||||
u1s.resize(nscales);
|
u1s.resize(nscales);
|
||||||
u2s.resize(nscales);
|
u2s.resize(nscales);
|
||||||
u3s.resize(nscales);
|
u3s.resize(nscales);
|
||||||
|
|
||||||
I0.convertTo(I0s[0], CV_32F, I0.depth() == CV_8U ? 1.0 : 255.0);
|
I0.convertTo(I0s[0], CV_32F, I0.depth() == CV_8U ? 1.0 : 255.0);
|
||||||
I1.convertTo(I1s[0], CV_32F, I1.depth() == CV_8U ? 1.0 : 255.0);
|
I1.convertTo(I1s[0], CV_32F, I1.depth() == CV_8U ? 1.0 : 255.0);
|
||||||
@ -94,7 +94,7 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::operator ()(const GpuMat& I0, const Gp
|
|||||||
|
|
||||||
u1s[0] = flowx;
|
u1s[0] = flowx;
|
||||||
u2s[0] = flowy;
|
u2s[0] = flowy;
|
||||||
u3s[0].create(I0.size(), CV_32FC1);
|
u3s[0].create(I0.size(), CV_32FC1);
|
||||||
|
|
||||||
I1x_buf.create(I0.size(), CV_32FC1);
|
I1x_buf.create(I0.size(), CV_32FC1);
|
||||||
I1y_buf.create(I0.size(), CV_32FC1);
|
I1y_buf.create(I0.size(), CV_32FC1);
|
||||||
@ -109,9 +109,9 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::operator ()(const GpuMat& I0, const Gp
|
|||||||
p11_buf.create(I0.size(), CV_32FC1);
|
p11_buf.create(I0.size(), CV_32FC1);
|
||||||
p12_buf.create(I0.size(), CV_32FC1);
|
p12_buf.create(I0.size(), CV_32FC1);
|
||||||
p21_buf.create(I0.size(), CV_32FC1);
|
p21_buf.create(I0.size(), CV_32FC1);
|
||||||
p22_buf.create(I0.size(), CV_32FC1);
|
p22_buf.create(I0.size(), CV_32FC1);
|
||||||
p31_buf.create(I0.size(), CV_32FC1);
|
p31_buf.create(I0.size(), CV_32FC1);
|
||||||
p32_buf.create(I0.size(), CV_32FC1);
|
p32_buf.create(I0.size(), CV_32FC1);
|
||||||
|
|
||||||
diff_buf.create(I0.size(), CV_32FC1);
|
diff_buf.create(I0.size(), CV_32FC1);
|
||||||
|
|
||||||
@ -139,8 +139,8 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::operator ()(const GpuMat& I0, const Gp
|
|||||||
{
|
{
|
||||||
u1s[s].create(I0s[s].size(), CV_32FC1);
|
u1s[s].create(I0s[s].size(), CV_32FC1);
|
||||||
u2s[s].create(I0s[s].size(), CV_32FC1);
|
u2s[s].create(I0s[s].size(), CV_32FC1);
|
||||||
}
|
}
|
||||||
u3s[s].create(I0s[s].size(), CV_32FC1);
|
u3s[s].create(I0s[s].size(), CV_32FC1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!useInitialFlow)
|
if (!useInitialFlow)
|
||||||
@ -148,7 +148,7 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::operator ()(const GpuMat& I0, const Gp
|
|||||||
u1s[nscales-1].setTo(Scalar::all(0));
|
u1s[nscales-1].setTo(Scalar::all(0));
|
||||||
u2s[nscales-1].setTo(Scalar::all(0));
|
u2s[nscales-1].setTo(Scalar::all(0));
|
||||||
}
|
}
|
||||||
u3s[nscales - 1].setTo(Scalar::all(0));
|
u3s[nscales - 1].setTo(Scalar::all(0));
|
||||||
|
|
||||||
// pyramidal structure for computing the optical flow
|
// pyramidal structure for computing the optical flow
|
||||||
for (int s = nscales - 1; s >= 0; --s)
|
for (int s = nscales - 1; s >= 0; --s)
|
||||||
@ -164,8 +164,8 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::operator ()(const GpuMat& I0, const Gp
|
|||||||
|
|
||||||
// zoom the optical flow for the next finer scale
|
// zoom the optical flow for the next finer scale
|
||||||
cuda::resize(u1s[s], u1s[s - 1], I0s[s - 1].size());
|
cuda::resize(u1s[s], u1s[s - 1], I0s[s - 1].size());
|
||||||
cuda::resize(u2s[s], u2s[s - 1], I0s[s - 1].size());
|
cuda::resize(u2s[s], u2s[s - 1], I0s[s - 1].size());
|
||||||
cuda::resize(u3s[s], u3s[s - 1], I0s[s - 1].size());
|
cuda::resize(u3s[s], u3s[s - 1], I0s[s - 1].size());
|
||||||
|
|
||||||
// scale the optical flow with the appropriate zoom factor
|
// scale the optical flow with the appropriate zoom factor
|
||||||
cuda::multiply(u1s[s - 1], Scalar::all(1/scaleStep), u1s[s - 1]);
|
cuda::multiply(u1s[s - 1], Scalar::all(1/scaleStep), u1s[s - 1]);
|
||||||
@ -179,10 +179,10 @@ namespace tvl1flow
|
|||||||
void warpBackward(PtrStepSzf I0, PtrStepSzf I1, PtrStepSzf I1x, PtrStepSzf I1y, PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf I1w, PtrStepSzf I1wx, PtrStepSzf I1wy, PtrStepSzf grad, PtrStepSzf rho);
|
void warpBackward(PtrStepSzf I0, PtrStepSzf I1, PtrStepSzf I1x, PtrStepSzf I1y, PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf I1w, PtrStepSzf I1wx, PtrStepSzf I1wy, PtrStepSzf grad, PtrStepSzf rho);
|
||||||
void estimateU(PtrStepSzf I1wx, PtrStepSzf I1wy,
|
void estimateU(PtrStepSzf I1wx, PtrStepSzf I1wy,
|
||||||
PtrStepSzf grad, PtrStepSzf rho_c,
|
PtrStepSzf grad, PtrStepSzf rho_c,
|
||||||
PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22, PtrStepSzf p31, PtrStepSzf p32,
|
PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22, PtrStepSzf p31, PtrStepSzf p32,
|
||||||
PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf u3, PtrStepSzf error,
|
PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf u3, PtrStepSzf error,
|
||||||
float l_t, float theta, float gamma, bool calcError);
|
float l_t, float theta, float gamma, bool calcError);
|
||||||
void estimateDualVariables(PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf u3, PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22, PtrStepSzf p31, PtrStepSzf p32, float taut);
|
void estimateDualVariables(PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf u3, PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22, PtrStepSzf p31, PtrStepSzf p32, float taut);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::cuda::OpticalFlowDual_TVL1_CUDA::procOneScale(const GpuMat& I0, const GpuMat& I1, GpuMat& u1, GpuMat& u2, GpuMat& u3)
|
void cv::cuda::OpticalFlowDual_TVL1_CUDA::procOneScale(const GpuMat& I0, const GpuMat& I1, GpuMat& u1, GpuMat& u2, GpuMat& u3)
|
||||||
@ -210,15 +210,15 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::procOneScale(const GpuMat& I0, const G
|
|||||||
GpuMat p11 = p11_buf(Rect(0, 0, I0.cols, I0.rows));
|
GpuMat p11 = p11_buf(Rect(0, 0, I0.cols, I0.rows));
|
||||||
GpuMat p12 = p12_buf(Rect(0, 0, I0.cols, I0.rows));
|
GpuMat p12 = p12_buf(Rect(0, 0, I0.cols, I0.rows));
|
||||||
GpuMat p21 = p21_buf(Rect(0, 0, I0.cols, I0.rows));
|
GpuMat p21 = p21_buf(Rect(0, 0, I0.cols, I0.rows));
|
||||||
GpuMat p22 = p22_buf(Rect(0, 0, I0.cols, I0.rows));
|
GpuMat p22 = p22_buf(Rect(0, 0, I0.cols, I0.rows));
|
||||||
GpuMat p31 = p31_buf(Rect(0, 0, I0.cols, I0.rows));
|
GpuMat p31 = p31_buf(Rect(0, 0, I0.cols, I0.rows));
|
||||||
GpuMat p32 = p32_buf(Rect(0, 0, I0.cols, I0.rows));
|
GpuMat p32 = p32_buf(Rect(0, 0, I0.cols, I0.rows));
|
||||||
p11.setTo(Scalar::all(0));
|
p11.setTo(Scalar::all(0));
|
||||||
p12.setTo(Scalar::all(0));
|
p12.setTo(Scalar::all(0));
|
||||||
p21.setTo(Scalar::all(0));
|
p21.setTo(Scalar::all(0));
|
||||||
p22.setTo(Scalar::all(0));
|
p22.setTo(Scalar::all(0));
|
||||||
p31.setTo(Scalar::all(0));
|
p31.setTo(Scalar::all(0));
|
||||||
p32.setTo(Scalar::all(0));
|
p32.setTo(Scalar::all(0));
|
||||||
|
|
||||||
GpuMat diff = diff_buf(Rect(0, 0, I0.cols, I0.rows));
|
GpuMat diff = diff_buf(Rect(0, 0, I0.cols, I0.rows));
|
||||||
|
|
||||||
@ -235,8 +235,8 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::procOneScale(const GpuMat& I0, const G
|
|||||||
{
|
{
|
||||||
// some tweaks to make sum operation less frequently
|
// some tweaks to make sum operation less frequently
|
||||||
bool calcError = (epsilon > 0) && (n & 0x1) && (prevError < scaledEpsilon);
|
bool calcError = (epsilon > 0) && (n & 0x1) && (prevError < scaledEpsilon);
|
||||||
cv::Mat m1(u3);
|
cv::Mat m1(u3);
|
||||||
estimateU(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, p31, p32, u1, u2, u3, diff, l_t, static_cast<float>(theta), gamma, calcError);
|
estimateU(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, p31, p32, u1, u2, u3, diff, l_t, static_cast<float>(theta), gamma, calcError);
|
||||||
if (calcError)
|
if (calcError)
|
||||||
{
|
{
|
||||||
error = cuda::sum(diff, norm_buf)[0];
|
error = cuda::sum(diff, norm_buf)[0];
|
||||||
@ -258,8 +258,8 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::collectGarbage()
|
|||||||
I0s.clear();
|
I0s.clear();
|
||||||
I1s.clear();
|
I1s.clear();
|
||||||
u1s.clear();
|
u1s.clear();
|
||||||
u2s.clear();
|
u2s.clear();
|
||||||
u3s.clear();
|
u3s.clear();
|
||||||
|
|
||||||
I1x_buf.release();
|
I1x_buf.release();
|
||||||
I1y_buf.release();
|
I1y_buf.release();
|
||||||
@ -274,9 +274,9 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::collectGarbage()
|
|||||||
p11_buf.release();
|
p11_buf.release();
|
||||||
p12_buf.release();
|
p12_buf.release();
|
||||||
p21_buf.release();
|
p21_buf.release();
|
||||||
p22_buf.release();
|
p22_buf.release();
|
||||||
p31_buf.release();
|
p31_buf.release();
|
||||||
p32_buf.release();
|
p32_buf.release();
|
||||||
|
|
||||||
diff_buf.release();
|
diff_buf.release();
|
||||||
norm_buf.release();
|
norm_buf.release();
|
||||||
|
@ -1082,7 +1082,7 @@ createOptFlow_DualTVL1
|
|||||||
.. ocv:member:: double gamma
|
.. ocv:member:: double gamma
|
||||||
|
|
||||||
parameter used for motion estimation. It adds a variable allowing for illumination variations
|
parameter used for motion estimation. It adds a variable allowing for illumination variations
|
||||||
Set this parameter to 1. if you have varying illumination.
|
Set this parameter to 1 if you have varying illumination.
|
||||||
See: [Chambolle2011]_
|
See: [Chambolle2011]_
|
||||||
|
|
||||||
|
|
||||||
|
@ -951,13 +951,13 @@ void EstimateVBody::operator() (const Range& range) const
|
|||||||
const float* I1wyRow = I1wy[y];
|
const float* I1wyRow = I1wy[y];
|
||||||
const float* u1Row = u1[y];
|
const float* u1Row = u1[y];
|
||||||
const float* u2Row = u2[y];
|
const float* u2Row = u2[y];
|
||||||
const float* u3Row = use_gamma?u3[y]:nullptr;
|
const float* u3Row = use_gamma?u3[y]:NULL;
|
||||||
const float* gradRow = grad[y];
|
const float* gradRow = grad[y];
|
||||||
const float* rhoRow = rho_c[y];
|
const float* rhoRow = rho_c[y];
|
||||||
|
|
||||||
float* v1Row = v1[y];
|
float* v1Row = v1[y];
|
||||||
float* v2Row = v2[y];
|
float* v2Row = v2[y];
|
||||||
float* v3Row = use_gamma ? v3[y]:nullptr;
|
float* v3Row = use_gamma ? v3[y]:NULL;
|
||||||
|
|
||||||
for (int x = 0; x < I1wx.cols; ++x)
|
for (int x = 0; x < I1wx.cols; ++x)
|
||||||
{
|
{
|
||||||
@ -1041,14 +1041,14 @@ float estimateU(const Mat_<float>& v1, const Mat_<float>& v2, const Mat_<float>&
|
|||||||
{
|
{
|
||||||
const float* v1Row = v1[y];
|
const float* v1Row = v1[y];
|
||||||
const float* v2Row = v2[y];
|
const float* v2Row = v2[y];
|
||||||
const float* v3Row = use_gamma?v3[y]:nullptr;
|
const float* v3Row = use_gamma?v3[y]:NULL;
|
||||||
const float* divP1Row = div_p1[y];
|
const float* divP1Row = div_p1[y];
|
||||||
const float* divP2Row = div_p2[y];
|
const float* divP2Row = div_p2[y];
|
||||||
const float* divP3Row = use_gamma?div_p3[y]:nullptr;
|
const float* divP3Row = use_gamma?div_p3[y]:NULL;
|
||||||
|
|
||||||
float* u1Row = u1[y];
|
float* u1Row = u1[y];
|
||||||
float* u2Row = u2[y];
|
float* u2Row = u2[y];
|
||||||
float* u3Row = use_gamma?u3[y]:nullptr;
|
float* u3Row = use_gamma?u3[y]:NULL;
|
||||||
|
|
||||||
|
|
||||||
for (int x = 0; x < v1.cols; ++x)
|
for (int x = 0; x < v1.cols; ++x)
|
||||||
@ -1333,7 +1333,7 @@ void OpticalFlowDual_TVL1::procOneScale(const Mat_<float>& I0, const Mat_<float>
|
|||||||
for (int n_inner = 0; error > scaledEpsilon && n_inner < innerIterations; ++n_inner)
|
for (int n_inner = 0; error > scaledEpsilon && n_inner < innerIterations; ++n_inner)
|
||||||
{
|
{
|
||||||
// estimate the values of the variable (v1, v2) (thresholding operator TH)
|
// estimate the values of the variable (v1, v2) (thresholding operator TH)
|
||||||
estimateV(I1wx, I1wy, u1, u2, u3, grad, rho_c, v1, v2, v3, l_t, gamma);
|
estimateV(I1wx, I1wy, u1, u2, u3, grad, rho_c, v1, v2, v3, l_t, static_cast<float>(gamma));
|
||||||
|
|
||||||
// compute the divergence of the dual variable (p1, p2, p3)
|
// compute the divergence of the dual variable (p1, p2, p3)
|
||||||
divergence(p11, p12, div_p1);
|
divergence(p11, p12, div_p1);
|
||||||
@ -1341,7 +1341,7 @@ void OpticalFlowDual_TVL1::procOneScale(const Mat_<float>& I0, const Mat_<float>
|
|||||||
if (use_gamma) divergence(p31, p32, div_p3);
|
if (use_gamma) divergence(p31, p32, div_p3);
|
||||||
|
|
||||||
// estimate the values of the optical flow (u1, u2)
|
// estimate the values of the optical flow (u1, u2)
|
||||||
error = estimateU(v1, v2, v3, div_p1, div_p2, div_p3, u1, u2, u3, static_cast<float>(theta), gamma);
|
error = estimateU(v1, v2, v3, div_p1, div_p2, div_p3, u1, u2, u3, static_cast<float>(theta), static_cast<float>(gamma));
|
||||||
|
|
||||||
// compute the gradient of the optical flow (Du1, Du2)
|
// compute the gradient of the optical flow (Du1, Du2)
|
||||||
forwardGradient(u1, u1x, u1y);
|
forwardGradient(u1, u1x, u1y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user