How can I do Video Skeletal Tracking through Kinect V2 in MATLAB?

3 次查看(过去 30 天)
I using Kinect for XBox One (Kinect V2) with Windows Adapter to do skeletal tracking through video in MATLAB. It is correctly identifying the location of joints but it is not joining them correctly. Therefore the lines are skewed and no proper skeleton is showing (see attached image). Also, fps are very low so the video is shaky. I am using MATLAB 2016a with Image Acquisition Toolbox Version 5.0, Microsoft Kinect for Windows Support from Image Acquisition Toolbox, Kinect for Windows Runtime 2.0 and Windows 10 64 bit. How can I correctly join the joints and increase fps? I am using the following code:
imaqreset;
%create color and depth kinect videoinput objects
colorVid = videoinput('kinect', 1);
depthVid = videoinput('kinect', 2, 'depth_512x424');
triggerconfig (depthVid,'manual');
framesPerTrig = 1
depthVid.FramesPerTrigger=framesPerTrig;
depthVid.TriggerRepeat=inf;
src = getselectedsource(depthVid);
src.EnableBodyTracking = 'on';
start(depthVid);
himg = figure
while ishandle(himg);
trigger (depthVid);
[depthMap, ~, depthMetaData] = getdata (depthVid);
imshow (depthMap, [0 4096]);
if sum(depthMetaData.IsBodyTracked) >0
skeletonJoints = depthMetaData.DepthJointIndices (:,:,depthMetaData.IsBodyTracked);
hold on;
plot (skeletonJoints(:,1), skeletonJoints(:,2),'*-');
hold off;
end
end
stop(depthVid);
  1 个评论
Izza Ali
Izza Ali 2017-12-20
Hi Rao, I am facing this same issue while using depth image. The joints are correctly placed but the interlinking lines are messed up. Also, how can i do skeleton tracking on RGB video?

请先登录,再进行评论。

回答(1 个)

Dymiargani Milono
try this one instead
imaqreset;
%create color and depth kinect videoinput objects
colorVid = videoinput('kinect', 1);
depthVid = videoinput('kinect', 2);
triggerconfig (depthVid,'manual');
framesPerTrig = 1;
depthVid.FramesPerTrigger=framesPerTrig;
depthVid.TriggerRepeat=inf;
src = getselectedsource(depthVid);
src.EnableBodyTracking = 'on';
start(depthVid);
himg = figure;
SkeletonConnectionMap = [ [4 3]; % Neck
[3 21]; % Head
[21 2]; % Right Leg
[2 1];
[21 9];
[9 10]; % Hip
[10 11];
[11 12]; % Left Leg
[12 24];
[12 25];
[21 5]; % Spine
[5 6];
[6 7]; % Left Hand
[7 8];
[8 22];
[8 23];
[1 17];
[17 18];
[18 19]; % Right Hand
[19 20];
[1 13];
[13 14];
[14 15];
[15 16];
];
while ishandle(himg);
trigger (depthVid);
[depthMap, ts, depthMetaData] = getdata (depthVid);
anyBodiesTracked = any(depthMetaData.IsBodyTracked ~= 0);
trackedBodies = find(depthMetaData.IsBodyTracked);
nBodies = length(trackedBodies);
colors = ['r';'g';'b';'c';'y';'m'];
imshow (depthMap, [0 4096]);
if sum(depthMetaData.IsBodyTracked) >0
skeletonJoints = depthMetaData.DepthJointIndices (:,:,depthMetaData.IsBodyTracked);
hold on;
for i = 1:24
for body = 1:nBodies
X1 = [skeletonJoints(SkeletonConnectionMap(i,1),1,body); skeletonJoints(SkeletonConnectionMap(i,2),1,body)];
Y1 = [skeletonJoints(SkeletonConnectionMap(i,1),2,body), skeletonJoints(SkeletonConnectionMap(i,2),2,body)];
line(X1,Y1, 'LineWidth', 2, 'LineStyle', '-' , 'Marker', '+', 'Color', colors(body));
end
end
hold off;
end
end
stop(depthVid);
  7 个评论
Homero Vladimir
Homero Vladimir 2023-4-20
Dymiargani.
I was not able to enable skeleton tracking.
I tried your code and works very well. Thanks !
Best regards,
Homero
Daniel Franco
Daniel Franco 2023-11-27
Good evening, congratulations on your work. I'm having problems with slow processing of the image (the frames). I saw that your code works one frame at a time, is there anything I can change to improve this aspect? Thank you very much in advance

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by