【问题标题】:How to synchronize kinect's color and depth sensors using matlab?如何使用 matlab 同步 kinect 的颜色和深度传感器?
【发布时间】:2019-06-04 08:36:09
【问题描述】:

我的教育项目是关于使用 Kinect 进行手势识别。我正在将 kinect 用于 XBox One 和适配器。

我使用以下代码从 kinect 录制了彩色和深度视频:(类似于所说的 here

clc
clear all
close all

imaqreset

%Call up dicertory containing utility functions
utilpath = fullfile(matlabroot, 'toolbox', 'imaq', 'imaqdemos', 'html', 'KinectForWindows');
addpath(utilpath);

%Create the videoinput objects for the colour and depth streams
colourVid = videoinput('kinect', 1, 'BGR_1920x1080');
depthVid = videoinput('kinect', 2, 'Depth_512x424');


depthSource = getselectedsource(depthVid);
depthSource.EnableBodyTracking = 'on';

%------------------------------------------------
%setting up record
%------------------------------------------------

% set the data streams to logging mode and to disk
set(colourVid, 'LoggingMode', 'Disk&Memory');
set(depthVid, 'LoggingMode', 'Disk&Memory');

%Set a video timeout property limit to 50 seconds 
set(colourVid, 'Timeout',50);
set(depthVid, 'Timeout',50);

%Creat a VideoReader object
colourLogfile = VideoWriter('colourTrial5.avi', 'Uncompressed AVI');
depthLogfile = VideoWriter('depthTrial5.mj2', 'Archival');

%configure the video input object to use the VideoWriter object
colourVid.DiskLogger = colourLogfile;
depthVid.DiskLogger = depthLogfile;

%set the triggering mode to 'manual'
triggerconfig([colourVid depthVid], 'manual');

%set the FramePerTrigger property of the VIDEOINPUT objects to 100 to
%acquire 100 frames per trigger.
set([colourVid depthVid], 'FramesPerTrigger', 100);


%------------------------------------------------
%Initiating the aquisition
%------------------------------------------------

%Start the colour and depth device. This begins acquisition, but does not
%start logging of acquired data
start([colourVid depthVid]);

pause(20); %allow time for both streams to start

%Trigger the devices to start logging of data.
trigger([colourVid depthVid]);

%Retrieve the acquired data
[colourFrameData, colourTimeData, colourMetaData] = getdata(colourVid);
[depthFrameData, depthTimeData, depthMetaData] = getdata(depthVid);


skeletonData = depthMetaData; %making copy of data 
save('skeletonData.mat','skeletonData')


stop([colourVid depthVid])

但是当我播放视频时,很明显这两个彩色和深度视频并不是同时录制的。我当前的实现在两个传感器之间存在延迟(几乎 1 秒!) 看来颜色传感器已经开始工作了,在深度传感器之前,然后,在拍摄了100帧之后,它在深度传感器之前停止了工作。 我希望两个传感器同步,以便每个传感器的视频在同一时刻。

为什么会这样?? 任何人都可以提出解决方案吗?

任何解决方案将不胜感激。 谢谢。

【问题讨论】:

  • 我没有使用此硬件的经验,但是录制的视频元数据是否没有时间戳或 fps 数据?这将有助于同步它们

标签: matlab triggers synchronization kinect video-recording


【解决方案1】:

查看您的代码,我认为它捕获正确,但捕获多个帧 epr 触发并播放它们?如果您直接保存带有时间戳的图像而不是视频(以查看是否有重复的帧),则可以检查这一点。所以你应该设置 FramePerTrigger 如下:

set([colourVid depthVid], 'FramesPerTrigger', 1);

或者,您可以使用我不久前创建的small utility;但它会保存带时间戳的图像。您可以根据附加的代码修改以保存到视频。希望这会有所帮助。

【讨论】:

  • 非常感谢您分享您的代码。关于 set([colourVid depthVid], 'FramesPerTrigger', 1); ,我之前做过这个,我有我在这里提到的问题 link
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-08-12
  • 2013-01-06
  • 2013-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多