Search code examples
pythononvif

python-onvif-zeep library - how to grab a frame?


I'm using an ONVIF IP security camera with the python-onvif-zeep library https://github.com/FalkTannhaeuser/python-onvif-zeep. Can anybody please provide a short, simple, and concise example that shows how to grab a frame?

The readme and the examples https://github.com/FalkTannhaeuser/python-onvif-zeep/tree/zeep/examples show how to set camera properties and some other things, but I can't find a working example that shows how to grab a frame.

For example, this is the simplest possible OpenCV program that grabs frames from the 1st attached webcam and shows them:

import cv2

def main():

    vidCap = cv2.VideoCapture(0)

    while True:

        frameGrabSuccessful, openCvImage = vidCap.read()

        cv2.imshow('openCvImage', openCvImage)

        keyPress = cv2.waitKey(1)
        if keyPress == 27 or keyPress == ord('q'):
            break
        # end if
    # end while

# end function

if __name__ == '__main__':
    main()

Can somebody please provide an equivalent example for the python-onvif-zeep library? i.e.:

from onvif import ONVIFCamera

def main():

    camera = ONVIFCamera('192.168.1.100', 80, 'username', 'pass')

    # what goes here ??

    while True:

        # what goes here ??

    # end while

# end function

if __name__ == '__main__':
    main()

Solution

  • Upon further investigation it seems python-onvif-zeep cannot be used for grabbing frames. It's necessary to use RTSP for that, see Access IP Camera in Python OpenCV