Real time skeleton tracking using kinect v2

조회 수: 14 (최근 30일)
Robert Bot
Robert Bot 2019년 2월 4일
댓글: Alessandra Martinez 2023년 1월 19일
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
prasanth s
prasanth s 2023년 1월 19일
편집: prasanth s 2023년 1월 19일
can you attach the input video 'depthVid'?
Alessandra Martinez
Alessandra Martinez 2023년 1월 19일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by