using kinect xbox one camera
2 views (last 30 days)
Show older comments
Hi All I am trying to do right now is to capture frames from the kinect color camera and preview them. for some reasons my code only show the last frame. _____________________________________________________--
vid = videoinput('kinect',1,'BGR_1920x1080');
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb')
vid.FrameGrabInterval = 5;
start(vid)
% Set a loop that stop after 100 frames of aquisition
while(vid.FramesAcquired<=500)
% Get the snapshot of the current fram
R=1+vid.FramesAcquired
data = getsnapshot(vid);
imshow(data)
hold on
z=0;
e=text(480,40, strcat('Between Angle: ', num2str((z))));
set(e, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'yellow');
hold off
end
stop(vid);
flushdata(vid);
_________________________________________________--
I am able to see the video(imshow) only at the last frame. I can't see the whole preview for soem reasons
0 Comments
Answers (2)
Don Zheng
on 17 Jul 2017
First of all, "vid.FramesAcquired<=500" stops when 500 frames are acquired, not 100. FrameGrabInterval only controls how many frames to skip before acquiring the next frame. You might want to use vid.FramesAvailable instead to approximate 100 acquired frames.
Please refer to the property list for detailed definitions of each parameter:
Also, it says "The frame of data returned is independent of the video input object FramesPerTrigger property and has no effect on the value of the FramesAvailable or FramesAcquired property."
This means that 'getsnapshot' is not controlling the loop because it is not controlling vid.FramesAcquired (or vid.FramesAvailable). Frame acquisition may happen any time during the script execution and there might be more than 1 frames being acquired during the execution of a loop. So the loop may be executed for (if not far) fewer than the expected number of times.
0 Comments
See Also
Categories
Find more on Kinect For Windows Sensor in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!