Skip to content

remove default stream sync in cuda TVL1 optical flow #3089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions modules/cudaoptflow/src/tvl1flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down