Using cv::cuda::stream for asynchronous processing of images in opencv
I am using OpenCV 3.4 with cuda libraries to process video images. Image is grabbed and uploaded over the device using GpuMat::upload(). Afterward the image is thresholded twice to create 2 different binary images (Th1 and Th2). My first question is that: Can I use cuda streams in both threshold functions to run at the same time? Is that a problem since they are both using the same GpuMat as input.
After the thresholding I will be using both binary GpuMats to do more processing on them using other cv::cuda functions. The second question is: Should I use Stream::waitForCompletion() to wait for the thresholding streams to be finished before using Th1 and Th2 for further processing? or this data dependency is automatically detected? basically I am trying to process this 2 binary images from here in parallel, not to process first Th1 and then th2. They are going to be processed exactly with similar cuda functions but with different values..
I am using cuda 9.0. Is it still a problem if same operation is enqueued twice with different data to different streams?