Main Content

ipcam

Create ipcam object to acquire images from an IP camera

Add-On Required: This feature requires the MATLAB Support Package for IP Cameras add-on.

Description

example

cam = ipcam('URL') creates the ipcam object cam, where URL is a character vector value that identifies a particular camera by its URL and connects it to the camera with that address. The URL must either be for a Motion JPEG (mjpeg) over HTTP or RTSP stream or H.264 over RTSP stream with basic authentication or digest authentication.

This way of creating the object requires no user authentication. When you create the ipcam object, it connects to the camera and you can then preview or acquire images.

example

cam = ipcam('URL', 'Timeout', Timeout) creates the ipcam object cam, where URL is a character vector value that identifies a particular camera by its URL and connects it to the camera with that address. The URL must either be for a Motion JPEG (mjpeg) over HTTP or RTSP stream or H.264 over RTSP stream with basic authentication or digest authentication.

The additional option Timeout can be used to set a timeout value other than the default of 10 seconds. The Timeout property specifies the amount of time that the snapshot function waits for data to be returned.

This way of creating the object requires no user authentication. When you create the ipcam object, it connects to the camera and you can then preview or acquire images.

example

cam = ipcam('URL', 'Username', 'Password') uses additional options to specify Username and Password when required for authentication by the camera.

example

cam = ipcam('URL', 'Username', 'Password', 'Timeout', Timeout) uses the additional option Timeout to set a Timeout value other than the default of 10 seconds. The Timeout property specifies the amount of time that the snapshot function waits for data to be returned.

Examples

collapse all

Use the ipcam function with the URL of the camera as the input argument to create the object and connect it to the camera with that address.

Create an object, cam, using the URL of the IP camera. The URL must be either for Motion JPEG (mjpeg) over HTTP or RTSP stream or for H.264 over RTSP stream. For information about finding the URL, see Find IP Camera URL.

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
             

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.

Use the ipcam function with Username as your user identifier, and Password as your user password, when required for authentication.

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.

Use the ipcam function with the URL of the camera and the optional Timeout argument to specify the timeout used during acquisition. The Timeout property specifies the amount of time in seconds that the snapshot function waits for data to be returned.

Create an object, cam, using the URL of the IP camera, and change the Timeout value from the default of 10 seconds.

cam = ipcam('http://172.28.17.193/video.mjpeg', '', '', 'Timeout', 20)
cam = 

Display Summary for ipcam:

             URL: 'http://172.28.17.193/video.mjpeg'
        Username: ''
        Password: ''
         Timeout: 20
             

The ipcam function creates the object, connects it to the IP camera, and sets the Timeout to 20 seconds. Timeout must appear last, after the URL, Username, and Password. If your camera does not require user authentication, you can just enter empty character vectors for the Username and Password arguments, as shown here. Timeout is a double data type and has a range of 0 to Inf. You can also change the value after object creation.

Input Arguments

collapse all

URL of the IP camera, specified as a character vector. This argument creates an ipcam object cam where URL is a character vector value that identifies a particular camera by its URL. When you use the ipcam function with the URL of the camera as the input argument, it creates the object and connects it to the camera with that address.

The URL must be for a Motion JPEG (mjpeg) overt HTTP or RTSP stream, or H.264 over RTSP stream.

The URL is made up of the IP address of the camera, followed by a video file designation, such as video.mjpeg or mjpg.cgi. If you do not know the URL to use for the camera, try the tips listed in Find IP Camera URL.

Example: cam= ipcam('http://172.28.17.193/video.mjpeg')

Data Types: char | string

User name for the IP camera, specified as a character vector. This argument creates an ipcam object cam where Username is a character vector value that identifies a particular camera by the user name required for authentication. When you use the ipcam function with the URL of the camera and the optional user name and password arguments, it creates the object and connects it to the camera with that URL address if the authentication is valid.

Use the Username argument, along with the Password argument, if the camera requires authentication. Username is the second argument.

Example: cam = ipcam('http://172.28.17.193/video.mjpeg', 'admin', 'myfoscam')

Data Types: char | string

Password for the IP camera, specified as a character vector. This argument creates an ipcam object cam where Password is a character vector value that identifies a particular camera by the user identification password for authentication. When you use the ipcam function with the URL of the camera and the optional user name and password arguments, it creates the object and connects it to the camera with that address if the authentication is valid.

Use the Password argument, along with the Username argument, if the camera requires authentication. Password is the third argument.

Example: cam = ipcam('http://172.28.17.193/video.mjpeg', 'admin', 'myfoscam')

Data Types: char | string

Timeout duration, specified as a numeric value, in seconds. The Timeout property specifies the amount of time that the snapshot function waits for data to be returned. This argument creates an ipcam object cam where Timeout is changed from the default of 10 seconds. When you use the ipcam function with the URL address of the camera and the optional Timeout argument, it creates the object and connects it to the camera with that address and uses the specified timeout during acquisition.

Timeout is the only name-value pair that the ipcam function accepts. Timeout is a double data type and has a range above 0 until Inf. It must appear last, after the URL, Username, and Password. If your camera does not require user authentication, you can just enter empty character vectors for the Username and Password arguments, as shown here. You can change the Timeout value after object creation, as described in Set Properties for IP Camera Acquisition.

Example: cam = ipcam('http://172.28.17.193/video.mjpeg', '', '', 'Timeout', 20)

Data Types: double

Version History

Introduced in R2015a