MATLAB: How to get the skeletal viewer to work

error in codekinectkinect v2

I use Matlab R2016a and a kinect v2 sensor. The code I use just doesn't seem to run and the same error keeps popping out. The code is:
imaqreset;
% Create color and depth kinect videoinput objects.
colorVid = videoinput('kinect', 1, RBG_1920x1080);
depthVid = videoinput('kinect', 2, depth_512x424);
triggerconfig(depthVid,'manual');
depthVid.FramesPerTrigger=1;
depthVid.TriggerRepeat=inf;
set(getselectedsource(depthVid),'TrackingMode','Skeleton');
viewer=vision.DeployableVideoPlayer();
start(depthVideo);
himg = figure;
while ishandle(himg)
trigger(depthVideo);
[depthMap, ~, depthMetaData]= getdata(depthVid);
imshow (depthMap, [0 4096]);
if sum(depthMetaData.IsSkeletonTracked)>0
skeletonJoints= depthMetaData.JoingtDepthIndices(:,:,depthMetaData.IsSkeletonTracked);
hold on;
plot(skeletonJoints(:,1), skeletonJoints(:,2),'*');
hold off;
end
end
stop(depthVid);
The error is The name 'TrackingMode' is not an accessible property for an instance of class 'videosource'. Also, at first the code ran smoothly up to the above mentioned error but later on it wouldn't even get past
colorVid= videoinput('kinect',1,'RBG_1920x1080');
saying that the adaptor name doesn't exist even though the kinect is connected. Please help! Thank you!

Best Answer

:::::::UPDATE AT END:::::::::::
This was an issue that caused me a lot of grief in the past. The problem is that only 2013 or older versions of Matlab support tracking with the kinect. I have debugged your code to do pretty much what you want it to. I do not know how to plot on the color video at the moment, but it does plot on the depth video. The updated code is in the attached file. Some of the old function names needed to be updated to the new names for the functions to work. Also, the third part of the adapter name was not necessary to run the program. It automatically uses the highest resolution for the selected camera unless you have changed the defaults for the kinect camera. Check which ones are default in imaqtool. If you are able to download R2013a this code should work just fine if you have all the necessary toolboxes and support packages. The attached screenshot shows the end result. It would work much better if I were standing. I hope this helps.
:::::UPDATE:::::
My information may not pertain to you. I am using an xbox 360 kinect that I chopped the cord off of and wired to usb and a 12 volt battery. Since you have an actual kinect for windows it may be supported past 2013. You may want to try the updated code and see how it goes from there.