Acquire Data from Kinect V1 Color and Depth Devices Simultaneously
You can synchronize the data from the Kinect® for Windows® color stream and the depth stream using software manual triggering.
This example shows the synchronization method used to manually trigger both objects.
Create the objects for the color and depth sensors. Device 1 is the color sensor and Device 2 is the depth sensor.
vid = videoinput('kinect',1); vid2 = videoinput('kinect',2);
Get the source properties for the depth device.
srcDepth = getselectedsource(vid2);
Set the frames per trigger for both devices to 1.
vid.FramesPerTrigger = 1; vid2.FramesPerTrigger = 1;
Set the trigger repeat for both devices to 200, in order to acquire 201 frames from both the color sensor and the depth sensor.
vid.TriggerRepeat = 200; vid2.TriggerRepeat = 200;
Configure the camera for manual triggering for both sensors.
Start both video objects.
Trigger the devices, then get the acquired data.
% Trigger 200 times to get the frames. for i = 1:200 % Trigger both objects. trigger([vid vid2]) % Get the acquired frames and metadata. [imgColor, ts_color, metaData_Color] = getdata(vid); [imgDepth, ts_depth, metaData_Depth] = getdata(vid2); end