【问题标题】:OpenCV capture doesn't work gets this problem MFVideoFormat_RGB24(codec not found),how can i solve?OpenCV capture does not work 得到这个问题 MFVideoFormat_RGB24(codec not found),我该如何解决?
【发布时间】:2020-10-08 22:10:33
【问题描述】:

我正在制作一个需要 openCV 库的 python 应用程序,这是我的代码:

# importing the required modules
import cv2
import numpy as np

# capturing from the first camera attached
cap = cv2.VideoCapture(0)

# will continue to capture until 'q' key is pressed
while True:
    ret, frame = cap.read()
    cv2.imshow('frame', frame)

    # Program will terminate when 'q' key is pressed
    if cv2.waitKey(1) & 0xFF == ord('q'): 
        break

# Releasing all the resources
cap.release()
cv2.destroyAllWindows()

当我运行代码时出现此错误:

[ WARN:0] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-wwma2wne\opencv\modules\videoio\src\cap_msmf.cpp (677) CvCapture_MSMF::initStream Failed to set mediaType (stream 0, (640x480 @ 30) MFVideoFormat_RGB24(codec not found)

我认为可能需要编解码器驱动程序,但我不知道如何修复错误 请朋友们帮帮我

【问题讨论】:

    标签: python opencv codec


    【解决方案1】:

    以下代码为我解决了这个问题:cap = cv2.VideoCapture(0,cv2.CAP_DSHOW)

    【讨论】:

      【解决方案2】:

      试试

      cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-12-09
        • 2015-08-22
        • 1970-01-01
        • 2020-02-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-01-12
        相关资源
        最近更新 更多