0

Am I missing something in trying to get frames from my ip camera over a network. The solution did not work at "Nonmatching transport in server reply" when cv2.VideoCapture rtsp onvif camera, how to fix? did not work for me.

Is there something missing in what I am doing? Background information:

  • OS Win 7 64-bit
  • Python - using both IDLE and DOS/cmd version, v3.8.5 - to show the error codes.
  • Open cv - version 3.4.4
  • Router, with address 192.168.1.1
  • Wireless adapter with address 192.168.1.100

Schematic diagram: IP Camera -> RJ45 into wireless router (192.168.1.1) -> air -> PC's wireless adapter (192.168.1.100) -> python computer program trying to decode the program. NOTE again: I can use other applications but cannot use opencv.

Where my IPCamera works:

My camera does communicate with other applications such as VLC player Video stream from the IPCamera can be played back the rstp stream via VLC player (3.0.11 Vetinari) and Media Player Classic (1.9.8.21) which uses FFMPEG and EVEN my android v5.1.1 smart phone. So there is no problem is receiving rstp streams from the IP Camera from other applications.

Note that VLC in python can be used as in the following code:

import vlc
player = vlc.MediaPlayer('rtsp://user:pword@192.168.1.183:554/onvif1')
player.play()
player.stop()

Note: user and pword are found at the bottom of the camera.

BUT I want to use opencv so as to extract the bytes from the 'frame'.

Code to replicate the problem:

import numpy as np
import cv2, os

#It does not matter which of the following os.environ assignments worked
os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;udp"
#os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;0"
#os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;tcp"
#os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "dummy"

# The url3 has been successfully used in VLC player and Media Player Classic Home. 
# BUT here the program stops 
url3 = "rtsp://user:pwrd@192.168.1.183:554/onvif1"

#cap = cv2.VideoCapture(url3)
cap = cv2.VideoCapture(url3,cv2.CAP_FFMPEG)
while(True):
    ret, frame = cap.read()
    #print(frame)
    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

There are two kinds of error messages when you run in both IDLE and the DOS/cmd line In the IDLE program you get the -215:assertion error, while in In IDLE:

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>/
cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-9d
_dfo3_\opencv\modules\highgui\src\window.cpp:376: error: (-215:Assertion failed)
 size.width>0 && size.height>0 in function 'cv::imshow'

In the DOS/cmd window:

Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np, cv2, os
>>> os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;0"
>>> url3 = "rtsp://user:pwrd@192.168.1.183:554/onvif1"
>>> cap = cv2.VideoCapture(url3, cv2.CAP_FFMPEG)
[rtsp @ 000000000050df80] Nonmatching transport in server reply

Further remarks: The program above stops after VideoCapture is instantiated as demonstrated by the DOS/cmd running and the insertion of the following code after instantiating VideoCapture in IDLE:

cap = cv2.VideoCapture(url3,cv2.CAP_FFMPEG)
cap.isOpened()
False

Please assist, thank you, Anthony of Sydney

  • I forgot to mention this code WORKED for a USB camera, that is replacing cap = cv2.VideoCapture(url3,cv2.CAP_FFMPEG) with cv2.VideoCapture(1) , the code WORKED. BUT DID NOT WORK for the ip camera – Anthony from Sydney Nov 10 '20 at 23:11
  • This code works with a USB camera. cap = cv2.VideoCapture(1) BUT not an IP camera Thank you, Anthony of Sydney – Anthony from Sydney Nov 10 '20 at 23:59
  • maybe [this](https://stackoverflow.com/q/66280861/1207193) might help you, your camera rtsp server is like mine, maybe? – imbr Feb 19 '21 at 18:32

0 Answers0