Set Properties for IP Camera Acquisition
IP Camera Properties
For IP cameras, device-specific properties cannot be set programmatically using
the ipcam
object. The snapshot
function uses
the resolution and other properties that are already set on the camera. However, you
can set device-specific properties using the webread
function.
See Change a Device-Specific Property Using webread.
When you create the ipcam
object, the object has four
properties that are used as input arguments — the URL, which is required, and
three optional properties that can be set when you create the object.
Property | Values |
---|---|
URL | URL of the IP camera, specified as a character vector. The URL is necessary to create the object. Other arguments are optional. The URL must either be for a MJPEG camera
over HTTP or RTSP stream or H.264 over RTSP stream. So the URL
must start with |
Username | User name for the IP camera, specified as a character vector. Use
the Username argument, along with the
Password argument, if the camera requires
authentication. Username is the second
argument. |
Password | Password for the IP camera, specified as a character vector. Use
the Password argument, along with the
Username argument, if the camera requires
authentication. Password is the third
argument. |
Timeout | Timeout duration, specified as a numeric, in seconds. The
|
Set the Timeout Property During Object Creation
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 theTimeout
value from the default of10
seconds. For information about finding the URL, see Troubleshooting Connection Issues to the IP Camera.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 and connects it to the IP camera with the specified URL, and sets theTimeout
to20
seconds.Timeout
must appear last, after theURL
,Username
, andPassword
. If your camera does not require user authentication, you can just enter empty character vectors for theUsername
andPassword
arguments, as shown here.After creating the object, you can preview the image and take snapshots from the camera. For more information, see Acquire Images from IP Cameras.
Set the Timeout Property After Object Creation
You can set the Timeout
property after object creation.
Create an object,
cam
, using the URL of the IP camera. For information about finding the URL, see Troubleshooting Connection Issues to 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
The
ipcam
function 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 theUsername
andPassword
properties are blank in the object display. The defaultTimeout
of10
is used if you do not specify the property when creating the object.Acquire a single image from the camera using the
snapshot
function, and assign it toimg
.img = snapshot(cam);
Display the acquired image.
imshow(img)
You can change the
Timeout
property any time after the object is created. In this case, increase it to 25 seconds.cam.Timeout = 25
Now when you use
snapshot
, the new duration of 25 seconds is in effect.
Change a Device-Specific Property Using webread
For IP cameras, device-specific properties cannot be set programmatically using
ipcam
. However, you can change camera properties using
webread
before creating the ipcam
object.
This example shows how to use webread
to change the brightness
of an IP camera.
Create a
weboptions
object.o = weboptions;
Set the
Username
of the IP camera.o.Username = 'admin'
Set the
Password
of the IP camera.o.Password = 'admin'
Use the
webread
function to set the brightness.webread('http://172.28.22.25/command/camera.cgi/?Brightness=1',o)
You can then create an
ipcam
object using the same camera and take snapshots, as described in Acquire Images from IP Cameras.
Note
You need to contact your camera vendor to get the URL to access properties.