tvl1 cuda optflow optimization

This commit is contained in:
Noah Stier 2021-10-27 12:01:53 -07:00
parent a0cf8c322d
commit 84a81579ba

View File

@ -162,7 +162,9 @@ namespace
GpuMat p32_buf;
GpuMat diff_buf;
GpuMat norm_buf;
GpuMat diff_sum_dev;
Mat diff_sum_host;
};
void OpticalFlowDual_TVL1_Impl::calc(InputArray _frame0, InputArray _frame1, InputOutputArray _flow, Stream& stream)
@ -361,8 +363,11 @@ namespace
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);
if (calcError)
{
cuda::calcSum(diff, diff_sum_dev, cv::noArray(), _stream);
diff_sum_dev.download(diff_sum_host, _stream);
_stream.waitForCompletion();
error = cuda::sum(diff, norm_buf)[0];
error = diff_sum_host.at<double>(0,0);
prevError = error;
}
else