You can use these functions with the VideoDevice System object™.
|Acquire a single frame from the image acquisition device.|
frame = step(obj);
a single frame from the VideoDevice System object,
Note that the first time you call step, it acquires exclusive use of the hardware and will start streaming data.
|Release VideoDevice resources and allow property value changes.|
system resources (such as memory, file handles, or hardware connections)
of System object,
|Returns a value that indicates if the VideoDevice resource
is locked. (Use |
L = isLocked(obj)
a logical value,
|Activate a live image preview window.|
a Video Preview window that displays live video data for the VideoDevice
|Close live image preview window.|
the live preview window for VideoDevice System object,
|Returns information about the object.|
information about the VideoDevice System object,
The basic workflow for using the VideoDevice System object is to create the object, preview the image, set any properties, acquire a frame, and clear the object, as shown here.
Construct a VideoDevice System object associated with the Winvideo adaptor with device ID of 1.
vidobj = imaq.VideoDevice('winvideo', 1);
Set an object-level property, such as
vidobj.ReturnedColorSpace = 'grayscale';
Note that the syntax for setting an object-level property is
= <property_value>, where the value can be a character
vector or a numeric.
Set a device-specific property, such as
vidobj.DeviceProperties.Brightness = 150;
Note that the syntax for setting a device-specific property
is to list the object name, the
and the property name using dot notation, and then make it equal to
the property value.
Preview the image.
Acquire a single frame using the
frame = step(vidobj);
Display the acquired frame.
Release the hardware resource.
Clear the VideoDevice System object.
You can return Kinect® for Windows® skeleton data using the VideoDevice System object on the Kinect Depth sensor.
Typically in the Image Acquisition Toolbox™, each camera or image device has one device ID. Because the Kinect for Windows camera has two separate sensors, the Color sensor and the Depth sensor, the toolbox lists two device IDs. The Kinect Color sensor is device 1 and the Kinect depth sensor is device 2.
This example uses a Kinect V1 device. The toolbox also supports Kinect V2. For information on the properties and metadata of Kinect V2 devices, install the Image Acquisition Toolbox Support Package for Kinect For Windows Sensor and see the "Acquire Images with Kinect V2" section in the documentation.
To create a System object using the Color sensor:
vidobjcolor = imaq.VideoDevice('kinect', 1);
To create a System object using the Depth sensor:
vidobjdepth = imaq.VideoDevice('kinect', 2);
The Depth sensor returns skeleton metadata. To access this,
you need to add a second output argument for the
The Color sensor works the same way as other devices. So acquiring
a frame using the Kinect Color sensor is done as shown here:
imageData = step(vidobjcolor);
imageData is the frame acquired if
a System object created with Device 1, the Kinect Color sensor.
The Kinect Depth sensor requires a second output argument, as shown here:
[depthData metadata] = step(vidobjdepth);
depthData is the frame acquired if
a System object created with Device 2, the Kinect Depth sensor, and
the skeleton metadata returned with the frame.
These metadata fields are related to tracking the skeletons. The metadata is returned as a structure that contains these parameters:
IsPositionTracked IsSkeletonTracked JointDepthIndices JointImageIndices JointTrackingState JointWorldCoordinates PositionDepthIndices PositionImageIndices PositionWorldCoordinates SegmentationData SkeletonTrackingID
You can then look at both outputs. To see the image frame:
To see the metadata output:
Note: The Kinect for Windows Depth sensor may take some seconds to be ready to begin acquiring skeletal metadata. In order to see values in the metadata output, you need to acquire multiple frames using the step function repeatedly. You can do this by using a for loop.
Note: By default the System object returns data as single precision values with the range 0.0 to 1.0. The value represents the fraction through the sensor's dynamic range. The Kinect depth sensor has a range of 0 to 8192 mm.
Acquiring Image and Skeletal Data Using Kinect is an example that shows how to access
the skeletal metadata using the
(not the VideoDevice System object), and it contains information about
the properties you can set on both the Color and Depth sensors, and
descriptions of all the metadata fields. The property names and values
are the same as they would be for the System object, but you would
then need to set the properties as shown in step 3 of the above example
(in the current topic) for use with the VideoDevice System object.