使用: cuda::DensePyrLKOpticalFlow时报错。
报错:
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(3.4.2) /home/xxx/Downloads/opencv-3.4.2/modules/cudaoptflow/src/pyrlk.cpp:240: error: (-215:Assertion failed) prevImg.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) in function 'dense'
Aborted (core dumped)
解决:
不要做浮点转换。去掉以下代码:
GpuMat d_frame0f;GpuMat d_frame1f;d_frame0.convertTo(d_frame0f, CV_32F, 1.0 / 255.0);d_frame1.convertTo(d_frame1f, CV_32F, 1.0 / 255.0);