python cv2.Videocapture() does not work, cap.isOpened() returns false

前端 未结 4 1485

cv2.Videocapture() works fine while using webcam but while trying to read from hard drive it shows error cap.isOpened() returns false

import cv2
import nump         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-02 08:55

    I was getting the same error while using opencv in anaconda3 virtual environment. I checked the buildinformation for current opencv version and ffmpeg was marked "no".

    To resolve this

    1. I uninstalled opencv from my conda environment (conda uninstall opencv)
    2. Installed latest ffmpeg using conda-forge channel (conda install -c conda-forge ffmpeg)

      Name Version Build Channel

      ffmpeg 4.0.2 ha6a6e2b_0 conda-forge

    3. Then installed opencv again using conda-forge channel (conda install -c conda-forge opencv)

      Name Version Build Channel

    opencv 3.4.1 py36_blas_openblash829a850_201 [blas_openblas] conda-forge

    Restart the python console after doing this and import cv2.

提交回复
热议问题