Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here is another rtsp cv2.VideoCapture onvif camera Nonmatching transport and -215:Assertion failed size and width > 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:

  • The camera does communicate with VLC (v3.0.11 Vetinari) player's video stream setting with URL = rtsp://user:[email protected]:554/onvif1 from the menu: Media -> Open Network Stream -> enter URL. That's with VLC.

  • The camera does communicate with other Media Player Classic (1.9.8.21) which uses FFMPEG. From the menu: File -> Open File/URL, and enter the URL = rtsp://user:[email protected]:554/onvif1.

  • Furthermore, I can use 'any' application on my PC to connect to the IPCamera via the router - for example ISpy. Since the IPCamera's signal goes through a router, my smartphone's Android v5.1.1 with WiFi set to on, I can use any ONVIF application installed on my smartphone.

  • A python program can be successfully connected to the IPCamera using VLC :

    import vlc player = vlc.MediaPlayer('rtsp://user:[email protected]:554/onvif1') player.play() player.stop()

  • In sum there is nothing wrong with the IP camera, the camera's signal can be read by any application such as VLC and Media Player classic using FFMPEG. Python can be used to view images from the IP Camera using VLC.

BUT I want to use opencv in order to use the bytes coming out of each frame.

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

Code to replicate the problem using opencv in both IDLE and DOS/cmd:

Here is the opencv implementation. It is after instantiation of the VideoCapture that the program does not proceed to the while loop. I used cv2's isOpened to determine that the program stops at instantiation of the VideoCapture.

    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. 
    url3 = "rtsp://user:[email protected]:554/onvif1"

   #cap = cv2.VideoCapture(url3)
   # BUT here the program stops once VideoCapture is instantiated, the program does not proceed to the while loop
    cap = cv2.VideoCapture(url3,cv2.CAP_FFMPEG)
   # When the cv2.isOpened, it is False
    cap.isOpened(); #prints False, and program does not proceed to the while loop. 
    while(True):
        ret, frame = cap.read()
        #print(frame)
        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    cap.release()
    cv2.destroyAllWindows()

Two kinds of errors - when running in IDLE and when running in a DOS/cmd line

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:

Running 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'

Running 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:[email protected]: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:

Remark: The program stops after VideoCapture is instantiated whether in the IDLE or DOS/cmd and does not proceed to the while loop.

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

Please assist,

thank you,

Anthony of Sydney

Here is another rtsp cv2.VideoCapture onvif camera Nonmatching transport and -215:Assertion failed size and width > 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
4.4.0
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:

  • The camera does communicate with VLC (v3.0.11 Vetinari) player's video stream setting with URL = rtsp://user:[email protected]:554/onvif1 from the menu: Media -> Open Network Stream -> enter URL. That's with VLC.

  • The camera does communicate with other Media Player Classic (1.9.8.21) which uses FFMPEG. From the menu: File -> Open File/URL, and enter the URL = rtsp://user:[email protected]:554/onvif1.

  • Furthermore, I can use 'any' application on my PC to connect to the IPCamera via the router - for example ISpy. Since the IPCamera's signal goes through a router, my smartphone's Android v5.1.1 with WiFi set to on, I can use any ONVIF application installed on my smartphone.

  • A python program can be successfully connected to the IPCamera using VLC :

    import vlc player = vlc.MediaPlayer('rtsp://user:[email protected]:554/onvif1') player.play() player.stop()

  • In sum there is nothing wrong with the IP camera, the camera's signal can be read by any application such as VLC and Media Player classic using FFMPEG. Python can be used to view images from the IP Camera using VLC.

BUT I want to use opencv in order to use the bytes coming out of each frame.

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

Code to replicate the problem using opencv in both IDLE and DOS/cmd:

Here is the opencv implementation. It is after instantiation of the VideoCapture that the program does not proceed to the while loop. I used cv2's isOpened to determine that the program stops at instantiation of the VideoCapture.

    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. 
    url3 = "rtsp://user:[email protected]:554/onvif1"

   #cap = cv2.VideoCapture(url3)
   # BUT here the program stops once VideoCapture is instantiated, the program does not proceed to the while loop
    cap = cv2.VideoCapture(url3,cv2.CAP_FFMPEG)
   # When the cv2.isOpened, it is False
    cap.isOpened(); #prints False, and program does not proceed to the while loop. 
    while(True):
        ret, frame = cap.read()
        #print(frame)
        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    cap.release()
    cv2.destroyAllWindows()

Two kinds of errors - when running in IDLE and when running in a DOS/cmd line

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:

Running 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'

Running 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:[email protected]: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:

Remark: The program stops after VideoCapture is instantiated whether in the IDLE or DOS/cmd and does not proceed to the while loop.

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

Please assist,

thank you,

Anthony of Sydney