如何修复opencv python cv2.VideoCapture rtsp onvif“服务器回复中的不匹配传输";错误? [英] How to fix opencv python cv2.VideoCapture rtsp onvif "nonmatching transport in server reply" error?

查看:403
本文介绍了如何修复opencv python cv2.VideoCapture rtsp onvif“服务器回复中的不匹配传输";错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用python 3.6.4的Windows上,通过pip安装了opencv(3.4).这是我正在使用的代码:

I'm on windows using python 3.6.4, installed opencv (3.4) through pip. Here's the code I'm using:

import numpy as np
import cv2

cap = cv2.VideoCapture('rtsp://192.168.15.116:554/onvif1')

while(cap.isOpened()):
    ret, frame = cap.read()

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

我遇到以下错误:

[rtsp @ 03858a40] Nonmatching transport in server reply
warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:808)
warning: rtsp://192.168.15.116:554/onvif1 (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:809)

我可以转到cmd并键入"ffplay rtsp://192.168.15.116/onvif1",视频将使用相同的rtsp地址在VLC中正常运行.使用cv2.VideoCapture(0)也可以与我的网络摄像头一起使用.

I can go to cmd and type "ffplay rtsp://192.168.15.116/onvif1" and the video will run as well as in VLC using the same rtsp address. Using cv2.VideoCapture(0) also works with my webcam.

试图将文件opencv_ffmpeg340.dll复制到所有路径文件夹中,但仍然无济于事.还检查了构建,除gstreamer之外,所有视频I/O都以是"显示.我没主意了.

Tried copying the file opencv_ffmpeg340.dll into all path folders, but still to no avail. Also checked build and all video I/O show up with YES, except gstreamer. I'm out of ideas.

推荐答案

我使用Microsoft的VCPKG在Windows 10上安装了OPENCV.之后,OPENCV可以正常工作-除非它无法打开视频文件.

I installed OPENCV onto Windows 10 using Microsoft's VCPKG. After which, OPENCV worked fine - except it would not open videos files.

没有成功,我尝试了许多建议.最后,对我有用的非常简单.我在Windows环境系统变量中将opencv的BIN文件夹包括为PATH.而已.现在,视频文件已打开并可以正常播放.

Without success, I tried many suggestions. Finally, what worked for me was very SIMPLE. I included opencv's BIN folder as a PATH in Windows Environment System Variables. That's it. Now, video files are opened and played just fine.

这篇关于如何修复opencv python cv2.VideoCapture rtsp onvif“服务器回复中的不匹配传输";错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆