From: Vitaly Tuzov Date: Tue, 4 Dec 2018 09:57:14 +0000 (+0300) Subject: Fixed static analyzer warnings in DISOpticalFlow X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1^2~388^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=388ccda85d148c5302e8996307f9188a85585f34;p=platform%2Fupstream%2Fopencv.git Fixed static analyzer warnings in DISOpticalFlow --- diff --git a/modules/video/src/dis_flow.cpp b/modules/video/src/dis_flow.cpp index 5176061..b86df15 100644 --- a/modules/video/src/dis_flow.cpp +++ b/modules/video/src/dis_flow.cpp @@ -226,9 +226,11 @@ DISOpticalFlowImpl::DISOpticalFlowImpl() border_size = 16; use_mean_normalization = true; use_spatial_propagation = true; + coarsest_scale = 10; /* Use separate variational refinement instances for different scales to avoid repeated memory allocation: */ int max_possible_scales = 10; + ws = hs = w = h = 0; for (int i = 0; i < max_possible_scales; i++) variational_refinement_processors.push_back(VariationalRefinement::create()); } @@ -1035,6 +1037,7 @@ void DISOpticalFlowImpl::Densification_ParBody::operator()(const Range &range) c sum_Uy += coef * Sy_ptr[is * dis->ws + js]; sum_coef += coef; } + CV_DbgAssert(sum_coef != 0); Ux_ptr[i * dis->w + j] = sum_Ux / sum_coef; Uy_ptr[i * dis->w + j] = sum_Uy / sum_coef; } diff --git a/modules/video/src/variational_refinement.cpp b/modules/video/src/variational_refinement.cpp index 677ae14..5bde55a 100644 --- a/modules/video/src/variational_refinement.cpp +++ b/modules/video/src/variational_refinement.cpp @@ -93,6 +93,7 @@ class VariationalRefinementImpl CV_FINAL : public VariationalRefinement int red_even_len, red_odd_len; int black_even_len, black_odd_len; + RedBlackBuffer(); void create(Size s); void release(); }; @@ -366,6 +367,10 @@ void VariationalRefinementImpl::updateRepeatedBorders(RedBlackBuffer &dst) } } +VariationalRefinementImpl::RedBlackBuffer::RedBlackBuffer() +{ + release(); +} void VariationalRefinementImpl::RedBlackBuffer::create(Size s) { /* Allocate enough memory to include borders */ @@ -386,6 +391,7 @@ void VariationalRefinementImpl::RedBlackBuffer::release() { red.release(); black.release(); + red_even_len = red_odd_len = black_even_len = black_odd_len = 0; } VariationalRefinementImpl::ParallelOp_ParBody::ParallelOp_ParBody(VariationalRefinementImpl &_var, vector _ops,