0

I need to connect to ip camera using Python. I am trying to do it like this:

import cv2

if __name__ == "__main__":
    cv2.namedWindow("original")
    cap = cv2.VideoCapture("<URL>")
    while True:
        flag, img = cap.read()
        try:
            cv2.imshow("original", img)
        except:
            cap.release()
            raise

        ch = cv2.waitKey(5)
        if ch == 27:
            break

    cap.release()
    cv2.destroyAllWindows()

I do not have direct access to the camera.
I have IP, port, username, password.
Model is Dahua DH-XVR4116HS-X.
I can't find the correct url.
I have tried rtsp://<username>:<password>@<ip>:<port>/cam/realmonitor?channel=<channelNo>&subtype=<typeNo> format but didn't get a result.
Do I need to enable multicasting?

Hewston
  • 316
  • 2
  • 5
  • Does this answer your question? [Access IP Camera in Python OpenCV](https://stackoverflow.com/questions/49978705/access-ip-camera-in-python-opencv) – Chandan Mar 04 '20 at 15:40

1 Answers1

0

Most likely the current camera port is closed, so you need to open the rtsp port and then try to connect.

Hewston
  • 316
  • 2
  • 5