Main Content

Connect to IP Cameras

Use the ipcam object to connect to a Motion JPEG or (mjpeg) over HTTP or RTSP stream or H.264 over RTSP stream. To create the object, you need the URL of the camera. If the camera requires authentication, specify a user name and password. To find the URL of your camera, see Find IP Camera URL.

Connect without User Authentication

  1. Create an object, cam, using only the URL of the IP camera.

    cam = ipcam('http://172.28.17.193/video.mjpeg')
    cam = 
    
    Display Summary for ipcam:
    
                 URL: 'http://172.28.17.193/video.mjpeg'
            Username: ''
            Password: ''
             Timeout: 10
                 

    It creates the object and connects it to the IP camera with the specified URL. This way of creating the object requires no user authentication, so the Username and Password properties are blank in the object display. A default Timeout of 10 is used if you do not specify the property when creating the object.

  2. After creating the object, you can preview the image and take snapshots from the camera. For more information, see Acquire Images from IP Cameras.

Connect with User Authentication

  1. Create an object, cam, using the URL of the IP camera, and the optional arguments for user authentication. Username is a character vector representing the user name for the IP camera, and must be the second argument. Password is a character vector representing the password for the IP camera, and must be the third argument.

    cam = ipcam('http://172.28.17.193/video.mjpeg', 'admin', 'myfoscam')
    cam = 
    
    Display Summary for ipcam:
    
                 URL: 'http://172.28.17.193/video.mjpeg'
            Username: 'admin'
            Password: '********'
             Timeout: 10
                 

    If the authentication is valid, it creates the object and connects it to the IP camera. The Password is shown as asterisks, for security reasons. If no password is entered, it shows a blank character vector.

  2. After creating the object you can preview the image and take snapshots from the camera. For more information, see Acquire Images from IP Cameras.

See Also