简体   繁体   English

OpenCV VideoCapture无法读取Windows 7 32bit中的任何视频文件

[英]OpenCV VideoCapture not read any video File in Windows 7 32bit

i try to read .avi or .mpeg video file using VideoCapture class of OpenCV2.4.8 in C++ using QtCreator and CMake 2.8.12.1. 我尝试使用QtCreator和CMake 2.8.12.1在C ++中使用OpenCV2.4.8的VideoCapture类读取.avi或.mpeg视频文件。 Before built OpenCV, i download FFMPEG static version and put them into Program Files directory, i add their path into enviroments variable PATH, then i download K Lite Codec Pack Full, install it and only then i built OpenCV with CMAKE and mingw provide by Qt. 在构建OpenCV之前,我先下载FFMPEG静态版本并将其放入Program Files目录,然后将其路径添加到环境变量PATH中,然后下载K Lite Codec Pack Full,安装它,然后才由Qt用CMAKE和mingw构建OpenCV。 。 After installation i add to PATH the right path of built OpenCV. 安装后,我将内置OpenCV的正确路径添加到PATH中。 The stream from webcam works fine, but the stream from a video file doesn't work. 来自网络摄像头的流可以正常工作,但是来自视频文件的流不起作用。 I tried on Windows 7 32bit and Windows 8 64bit. 我在Windows 7 32bit和Windows 8 64bit上尝试过。 Here is the code 这是代码

#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include "opencv2/opencv.hpp"
cv::Mat img;
cv::VideoCapture cap("Prova.avi");
std::cerr << cap.isOpened() << std::endl;
while(cap.read(img)){
    cv::imshow("Opencv", img);
    cv::waitKey(33);
}

The same code works on Ubuntu 12.04 with the same version of OpenCV and with the ffmpeg build by myself. 相同的代码在具有相同版本的OpenCV和由我自己构建的ffmpeg的Ubuntu 12.04上可以工作。 What is wrong? 怎么了?

Download the file opencv_ffmpeg.dll . 下载文件opencv_ffmpeg.dll I got it from this 我是从这里得到的

Now rename the opencv_ffmpeg.dll according to the opencv version you are using. 现在根据您使用的opencv版本重命名opencv_ffmpeg.dll For OpenCv 2.4.8 rename it as opencv_ffmpeg248.dll and add the location of this file to the PATH in environment variable. 对于OpenCv 2.4.8,将其重命名为opencv_ffmpeg248.dll然后将此文件的位置添加到环境变量中的PATH中。 Now try to run your program. 现在尝试运行您的程序。

For some unknown reason in a system 32bit the building created a dll called opencv_ffmpeg248_64.dll and the installation of opencv was in a folder "x64", so i think that dll was for 64bit system. 由于某些未知原因,该建筑物在32位系统中创建了一个名为opencv_ffmpeg248_64.dll的dll,而opencv的安装位于文件夹“ x64”中,因此我认为该dll适用于64位系统。 I download the pre built version of openCV and i use the dll included in that package. 我下载了openCV的预构建版本,并且使用了该软件包中包含的dll。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM