Hi All,
I am currently working with the Kinect V2 to develop a method of tracking respiratory motion.
How can I model and plot the depth changes over time? From looking into the array the depth image stores, the depth seems to be an index between the height and width.
For simplicity I want to plot the depth changes of a 5x5 pixel square in the center of the screen over 300 frames, so roughly 10 seconds. (I'll change the frequency to fixed 10 Hz later) but right now i'm stuck on the basics.
Any help would be appreciated!
Thank you in advance.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 26 de Jun. de 2019
Editada: Walter Roberson el 26 de Jun. de 2019

0 votos

maxFrame = 300;
vid = videoinput('kinect', 2); %1 for color, 2 for depth
vid.FramesPerTrigger = 1;
vid.TriggerRepeat = maxFrame;
start(vid);
for nFrame = 1 : maxFrame
d = getdata(vid);
[h,w,p] = size(d);
hh = floor(h/2);
hw = floor(w/2);
d55 = d(hh-2:hh+2, hw-2:hw+2,:);
...
end

4 comentarios

Anthony Foti
Anthony Foti el 26 de Jun. de 2019
Hey Walter,
Thank you for the quick reply!
I am receiving an error "Index in position 1 exceeds array bounds (must not exceed
424)."
Walter Roberson
Walter Roberson el 26 de Jun. de 2019
I have adjusted the code. You might want to double-check the behavior on even vs odd sized matrices as to what it means to take a " 5x5 pixel square in the center of the screen"
Anthony Foti
Anthony Foti el 26 de Jun. de 2019
Sorry, reading that back makes it sound silly. I appreicate and have accepted your answer!
Walter Roberson
Walter Roberson el 27 de Jun. de 2019
No it isn't silly: it is just that typically the arrays are even length and then it becomes a challenge to say what the center pixel is.

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 26 de Jun. de 2019

Comentada:

el 27 de Jun. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by