From eb6c598678ea55e6a74baa58f12cb04c0855e9f9 Mon Sep 17 00:00:00 2001 From: Ernest Galbrun Date: Mon, 7 Jul 2014 09:32:48 +0200 Subject: [PATCH] changed nullptr to NULL to avoid c++11 (failed to build on linux) replaces tabs with spaces --- .../include/opencv2/cudaoptflow.hpp | 24 ++++----- modules/cudaoptflow/src/tvl1flow.cpp | 54 +++++++++---------- .../motion_analysis_and_object_tracking.rst | 2 +- modules/video/src/tvl1flow.cpp | 14 ++--- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/modules/cudaoptflow/include/opencv2/cudaoptflow.hpp b/modules/cudaoptflow/include/opencv2/cudaoptflow.hpp index fa66ec1666..d07a834ef3 100644 --- a/modules/cudaoptflow/include/opencv2/cudaoptflow.hpp +++ b/modules/cudaoptflow/include/opencv2/cudaoptflow.hpp @@ -211,13 +211,13 @@ public: * The method is stable for a large range of values of this parameter. */ - double gamma; - /** - * parameter used for motion estimation. It adds a variable allowing for illumination variations - * 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 - * Journal of Mathematical imaging and vision, may 2011 Vol 40 issue 1, pp 120-145 - */ + double gamma; + /** + * parameter used for motion estimation. It adds a variable allowing for illumination variations + * 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 + * Journal of Mathematical imaging and vision, may 2011 Vol 40 issue 1, pp 120-145 + */ double theta; /** @@ -254,8 +254,8 @@ private: std::vector I0s; std::vector I1s; std::vector u1s; - std::vector u2s; - std::vector u3s; + std::vector u2s; + std::vector u3s; GpuMat I1x_buf; GpuMat I1y_buf; @@ -270,9 +270,9 @@ private: GpuMat p11_buf; GpuMat p12_buf; GpuMat p21_buf; - GpuMat p22_buf; - GpuMat p31_buf; - GpuMat p32_buf; + GpuMat p22_buf; + GpuMat p31_buf; + GpuMat p32_buf; GpuMat diff_buf; GpuMat norm_buf; diff --git a/modules/cudaoptflow/src/tvl1flow.cpp b/modules/cudaoptflow/src/tvl1flow.cpp index bf1c026a21..eba0fe96dd 100644 --- a/modules/cudaoptflow/src/tvl1flow.cpp +++ b/modules/cudaoptflow/src/tvl1flow.cpp @@ -64,7 +64,7 @@ cv::cuda::OpticalFlowDual_TVL1_CUDA::OpticalFlowDual_TVL1_CUDA() epsilon = 0.01; iterations = 300; scaleStep = 0.8; - gamma = 0.0; + gamma = 0.0; useInitialFlow = false; } @@ -81,7 +81,7 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::operator ()(const GpuMat& I0, const Gp I1s.resize(nscales); u1s.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); 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; u2s[0] = flowy; - u3s[0].create(I0.size(), CV_32FC1); + u3s[0].create(I0.size(), CV_32FC1); I1x_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); p12_buf.create(I0.size(), CV_32FC1); p21_buf.create(I0.size(), CV_32FC1); - p22_buf.create(I0.size(), CV_32FC1); - p31_buf.create(I0.size(), CV_32FC1); - p32_buf.create(I0.size(), CV_32FC1); + p22_buf.create(I0.size(), CV_32FC1); + p31_buf.create(I0.size(), CV_32FC1); + p32_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); 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) @@ -148,7 +148,7 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::operator ()(const GpuMat& I0, const Gp u1s[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 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 cuda::resize(u1s[s], u1s[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(u2s[s], u2s[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 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 estimateU(PtrStepSzf I1wx, PtrStepSzf I1wy, PtrStepSzf grad, PtrStepSzf rho_c, - PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22, PtrStepSzf p31, PtrStepSzf p32, - PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf u3, PtrStepSzf error, + PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22, PtrStepSzf p31, PtrStepSzf p32, + PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf u3, PtrStepSzf error, 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) @@ -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 p12 = p12_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 p31 = p31_buf(Rect(0, 0, I0.cols, I0.rows)); - GpuMat p32 = p32_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 p32 = p32_buf(Rect(0, 0, I0.cols, I0.rows)); p11.setTo(Scalar::all(0)); p12.setTo(Scalar::all(0)); p21.setTo(Scalar::all(0)); - p22.setTo(Scalar::all(0)); - p31.setTo(Scalar::all(0)); - p32.setTo(Scalar::all(0)); + p22.setTo(Scalar::all(0)); + p31.setTo(Scalar::all(0)); + p32.setTo(Scalar::all(0)); 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 bool calcError = (epsilon > 0) && (n & 0x1) && (prevError < scaledEpsilon); - cv::Mat m1(u3); - estimateU(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, p31, p32, u1, u2, u3, diff, l_t, static_cast(theta), gamma, calcError); + cv::Mat m1(u3); + estimateU(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, p31, p32, u1, u2, u3, diff, l_t, static_cast(theta), gamma, calcError); if (calcError) { error = cuda::sum(diff, norm_buf)[0]; @@ -258,8 +258,8 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::collectGarbage() I0s.clear(); I1s.clear(); u1s.clear(); - u2s.clear(); - u3s.clear(); + u2s.clear(); + u3s.clear(); I1x_buf.release(); I1y_buf.release(); @@ -274,9 +274,9 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::collectGarbage() p11_buf.release(); p12_buf.release(); p21_buf.release(); - p22_buf.release(); - p31_buf.release(); - p32_buf.release(); + p22_buf.release(); + p31_buf.release(); + p32_buf.release(); diff_buf.release(); norm_buf.release(); diff --git a/modules/video/doc/motion_analysis_and_object_tracking.rst b/modules/video/doc/motion_analysis_and_object_tracking.rst index 43bd3b74cc..805c0f62fa 100644 --- a/modules/video/doc/motion_analysis_and_object_tracking.rst +++ b/modules/video/doc/motion_analysis_and_object_tracking.rst @@ -1082,7 +1082,7 @@ createOptFlow_DualTVL1 .. ocv:member:: double gamma 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]_ diff --git a/modules/video/src/tvl1flow.cpp b/modules/video/src/tvl1flow.cpp index 25096683b5..f251b95ba0 100644 --- a/modules/video/src/tvl1flow.cpp +++ b/modules/video/src/tvl1flow.cpp @@ -951,13 +951,13 @@ void EstimateVBody::operator() (const Range& range) const const float* I1wyRow = I1wy[y]; const float* u1Row = u1[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* rhoRow = rho_c[y]; float* v1Row = v1[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) { @@ -1041,14 +1041,14 @@ float estimateU(const Mat_& v1, const Mat_& v2, const Mat_& { const float* v1Row = v1[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* 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* 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) @@ -1333,7 +1333,7 @@ void OpticalFlowDual_TVL1::procOneScale(const Mat_& I0, const Mat_ for (int n_inner = 0; error > scaledEpsilon && n_inner < innerIterations; ++n_inner) { // 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(gamma)); // compute the divergence of the dual variable (p1, p2, p3) divergence(p11, p12, div_p1); @@ -1341,7 +1341,7 @@ void OpticalFlowDual_TVL1::procOneScale(const Mat_& I0, const Mat_ if (use_gamma) divergence(p31, p32, div_p3); // 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(theta), gamma); + error = estimateU(v1, v2, v3, div_p1, div_p2, div_p3, u1, u2, u3, static_cast(theta), static_cast(gamma)); // compute the gradient of the optical flow (Du1, Du2) forwardGradient(u1, u1x, u1y);