This is a 2-part post series (2nd part here), where we can see how to save the data acquired from Kinect connected to the USB port to disk in png images and the load it in matlab for further processing.
As of 2013a release, Matlab Image Acquisition Toolbox supports data acquisition from Kinect v1 out of the box. In 2016a, support for Kinect v2 was also rolled out for windows 8 and later . Matlab uses the Kinect windows drivers to acquire the data from a Kinect connected to the USB port.
In this post, I am going to show you a small Matlab based application to acquire and save the images to disk for later use. The images acquired by the application are saved in two sub-folders (RGB and Depth) in a folder. The filenames of the recorded frames will be the timestamps of the acquired images, so the same RGB and depth images can be cross correlated if required. This was a quick application I wrote a while back to capture and analyse data from Kinect v2.
The Matlab files can be downloaded at the bottom of this post. I won’t get into details on how the GUI has been developed, however, I will explain some important parts of the code.

Running the application

To save the acquired data, first the number of frames have to be set using the slider in the GUI anywhere from 1 to 250 (default = 1). Once the slider is set, the “Start DAQ” button can be clicked to save the files. In order to preview the field of view, the radio buttons in the “Preview Options” can be selected as required.

Dataset save path

After clicking this button, a standard directory selection dialog box opens up. Once the folder is selected, 2 folders are automatically created for saving the files if they do not already exist.

Start data acquisition

On clicking the start button, matlab checks if there is a Kinect device connected to the PC. If the device is found, it’s info is printed ou on the console.

The FramesPerTrigger option, sets the frame acquisition to every frame. This can be set to larger numbers to reduce the amount of data or add some gap between each frame acquired.

To generate the file name, the timestamp of the acquired image is used. This is done using the following

Once the number of frames are captured, a message box is displayed showing the time elapsed. Also, always remember to reset the image acquisition hardware, freeing it up for other applications, or for matlab itself to use.

In the second part of this blog post, I will show how to display the loaded images and visualize the depth data acquired.

Download the code from HERE.