Real time skeleton tracking using kinect v2

I'm trying to use this code using kinect v2 to get real time skeleton tracking. I'm using matlab R2018a.
clear; close all;clc
imaqreset;
depthVid = videoinput('kinect',2);
triggerconfig (depthVid,'manual');
framesPerTrig = 1;
depthVid.FramesPerTrigger = framesPerTrig;
depthVid.TriggerRepeat = inf;
prop = getselectedsource(depthVid);
prop.EnableBodyTracking = 'on';
start(depthVid)
himg = figure;
while ishandle(himg);
trigger(depthVid)
[frameDataDepth, timeDataDepth, metaDataDepth] = getdata(depthVid)
if sum(metaDataDepth.IsBodyTracked) > 0
skeletonJoints = metaDataDepth.JointPositions(:,:,metaDataDepth.IsBodyTracked)
try
delete(h)
end
h = plot(skeletonJoints(:,1), skeletonJoints(:,2),'.','MarkerSize',15); % Plota no imshow as juntas
axis([-2.1 2.1 -2.1 2.1])
end
end
This code does work, but it has a big delay, when i used:
tic
trigger(depthVid)
toc
The elapsed time is 1.002209 seconds
The trigger made my code runing slow, how can i fix it? Is there a way to reduce trigger time? The FPS are very slow.
Notice that the elapsed time to trigger is big (1sec) just when i enable body tracking (i need to use it, since i want to get real time skeleton tracking). When i tried without using body tracking property the trigger time was arround 0.003 seconds, the idial for the application.
Thank you!

4 Comments

Hi Robert!
Did you managed to solve your problem? I am facing a similar problem, the trigger of the depth Video takes too long. Any tips?
Thanks!
Hey did you fixed it? I'm having a similar issue, there's a gap betwene the RGB image and the skeleton
can you attach the input video 'depthVid'?
I don't have a saved input video. I'm trying to make it real time, however the RGB image isn't synched with the plotted skeleton. I'm using imshow() though.
I could attach the code I'm working with.

Sign in to comment.

Answers (0)

Products

Asked:

on 4 Feb 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!