Starting from OpenCV 4.1.1, the NVidia Optflow sdk is taken into account in cudaoptflow.
However, because of the use of
cuCtxGetCurrent(), cuCtxPopCurrent(), cuCtxPushCurrent(), cuCtxSynchronize(),
then opencv_cudaoptflow411.dll fails to load, and prevents a program from running if nvcuda.dll is not available on the host machine.
A solution under windows+Visual Studio is to "Delay load" opencv_cudaoptflow411.dll, but it is less convenient than unders OpenCV <= 4.1.0, where checking at runtime for "cv::cuda::getCudaEnabledDeviceCount()" was enough to decide if cuda was available.