Python27+Opencv3 Vid

发布时间:2019-09-24 08:36:13编辑:auto阅读(1641)

    最近在win10 X64部署了Python27 win32 + Opencv3的环境,具体过程记录于其他博文。

    进行图片的相关操作等均正常,但是在操作视频时,出现了问题。具体如下


    代码:

    Cap = cv2.VideoCapture('******')

    #判断是否正常开启

    print Cap.isOpened()


    1、*********为*.avi文件,打印返回FALSE

    2、*********为摄像头,打印返回FALSE


    处理:

    1、搜索良久,stackoverflow已有大神给出解决方法

    http://stackoverflow.com/questions/11699298/opencv-2-4-videocapture-not-working-on-windows

    Add C:\OpenCV\3rdparty\ffmpeg\ to the Windows PATH environment variable or copy opencv_ffmpeg.dll from that directory to C:\Python27\ or to a directory that is in the PATH. 


    拷贝dll文件或者将ffmpeg加入系统变量,试了下,not worked!


    2、同一帖子下,有其他人回复如下:

     first tried copying, then changing the Path environment of windows.. it didn't work until i changed the name to opencv_ffmpeg245.dll for my openCV version 2.4.5 and python 2.7. (notice **245.dll is from opencv version 2.4.5)


    修改dll文件名,加上对应opencv版本号,试了下,not worked!


    3、在往下看,又有大神回复解决方式:

    I had the same issue with python 2.7 and opencv 2.4.10. I copied the opencv_ffmpeg2410_64.dll file from C:\Applications\opencv\build\x64\vc10\bin into the python path (mine is at C:\Users\mohammad\Anaconda) and it was solved!


    其他opencv路径中已有带版本号的对应dll文件,拷贝之,worked!

    比如我的该dll文件路径:C:\opencv\build\x86\vc12\bin\opencv_ffmpeg300.dll

    wKiom1fYtxGwdBmjAABQt7kvC9w403.png-wh_50



关键字