Opencv报错004:cv::VideoCapture无法读取本地视频文件,报错:cv::CvCapture_Images::open CAP_IMAGES: Stop scanning. Can‘

环境描述:
– Window10
– VS2019
– Opencv 4.5.5

代码demo如下(主要是在自定义的视频读取函数):

void Optical_Flow::video_process(string Video_path) {
	cv::VideoCapture capture(Video_path);
	if (!capture.isOpened())
	{
		std::cout << "Read video Failed !" << std::endl;
		return;
	}
	while (true) {
		Mat frame;
		capture >> frame;

		//Mat frame_gray;
		//cv::cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
		imshow("frame", frame);

		if (waitKey(1) == 27) {
			break;
		}
	}
}

错误描述:使用opencv中 “cv::VideoCapture” 函数,无法读取本地文件;
报错内容显示:“Read video Failed”,即无法打开该视频文件;
Opencv报错004:cv::VideoCapture无法读取本地视频文件,报错:cv::CvCapture_Images::open CAP_IMAGES: Stop scanning. Can‘_第1张图片
错误分析:原因一般出在 “ffmpeg” 这个库上面,个人安装的是opencv4.5.5版本,所以该库全程为:opencv_videoio_ffmpeg455_64.dll,该文件在opencv本地安装路径的 "build/x64/vc15/bin"文件夹下;

**解决方法:**将 "opencv_videoio_ffmpeg455_64.dll"文件copy到本地电脑 "c:\Windows\System32"文件夹路径下,即可解决问题。

欢迎指正!

你可能感兴趣的:(opencv)