Skip to content

Commit 92987f8

Browse files
committed
Merge pull request #3089 from noahstier:tlv1_cuda_optimization
2 parents 3db7682 + e245d4a commit 92987f8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/cudaoptflow/src/tvl1flow.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ namespace
162162
GpuMat p32_buf;
163163

164164
GpuMat diff_buf;
165-
GpuMat norm_buf;
165+
166+
GpuMat diff_sum_dev;
167+
Mat diff_sum_host;
166168
};
167169

168170
void OpticalFlowDual_TVL1_Impl::calc(InputArray _frame0, InputArray _frame1, InputOutputArray _flow, Stream& stream)
@@ -361,8 +363,11 @@ namespace
361363
estimateU(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, p31, p32, u1, u2, u3, diff, l_t, static_cast<float>(theta_), gamma_, calcError, stream);
362364
if (calcError)
363365
{
366+
cuda::calcSum(diff, diff_sum_dev, cv::noArray(), _stream);
367+
diff_sum_dev.download(diff_sum_host, _stream);
364368
_stream.waitForCompletion();
365-
error = cuda::sum(diff, norm_buf)[0];
369+
370+
error = diff_sum_host.at<double>(0,0);
366371
prevError = error;
367372
}
368373
else

0 commit comments

Comments
 (0)