主要内容

用于Kinect V2骨架数据的骨架查看器

此示例显示了如何查看使用Kinect V2拍摄的RGB图像,其中骨骼关节位置覆盖在图像上。

运行此示例的要求

1. Matlab和图像采集工具箱。

2. Windows V2传感器的Kinect。

3.最小PC配置:Windows 8 64位,带有专用USB3控制器。

设置Kinect V2以进行颜色和深度采集。

%创建颜色和深度kinect视频输出对象。ColorVid = VideoInput('Kinect',1)深度= VideoInput('Kinect'2)%看深度源设备上的设备特定属性,%是Kinect V2上的深度传感器。%将“EnableBodyTracking”设置为ON,以便深度传感器将%返回身体跟踪元数据以及深度帧。depthsource = getSelectedSource(Depryvid);DepteSource.enableBodyTracking ='在';%获得100个颜色和深度帧。FramesPertrig = 100;colorvid.framespertrigger = framespertrig;DemantVid.FramesPertrigger = FramesPertrig;%启动深度和彩色采集对象。%这开始采集,但不能开始记录获取的数据。暂停(5);开始([深度ColorVid]);
视频输入对象使用“Kinect V2颜色传感器”摘要。获取源:Kinect V2颜色源可用。采集参数:'Kinect V2颜色源'是当前所选源。每个触发器使用所选源10帧。'bgr_1920x1080'在开始时要记录的视频数据。首先抓住每1帧。将数据记录到触发器上的“内存”。触发参数:启动时1'立即'触发器。状态:等待开始。自开始以来获取0帧。 0 frames available for GETDATA. Summary of Video Input Object Using 'Kinect V2 Depth Sensor'. Acquisition Source(s): Kinect V2 Depth Source is available. Acquisition Parameters: 'Kinect V2 Depth Source' is the current selected source. 10 frames per trigger using the selected source. 'Depth_512x424' video data to be logged upon START. Grabbing first of every 1 frame(s). Log data to 'memory' on trigger. Trigger Parameters: 1 'immediate' trigger(s) on START. Status: Waiting for START. 0 frames acquired since starting. 0 frames available for GETDATA.

访问图像和骨架数据。

%从颜色和深度设备对象获取图像和元数据。[colorimg] = getData(colorvid);[〜,〜,元数据] = getData(深度);%这些是Kinect适配器返回的关节顺序。%spinebase = 1;%Spinemid = 2;%颈部= 3;%头= 4;%肩膀= 5;%elbowleft = 6;%wristleft = 7;%handleft = 8;%突发= 9;%ElbowRight = 10;%wristright = 11;%手ri= 12;%hipleft = 13;%kneeleft = 14;%Ankleleft = 15;%footleft = 16;%Hipright = 17;%脚背= 18;%Ankleright = 19;%脚踏杆= 20;%spineshoulder = 21;%handtipleft = 22;%曲折= 23;%handtiphight = 24;%thumbright = 25;%创建骨架连接映射以链接关节。skeletonconnectionmap = [[4 3];% 脖子[3 21];% 头[21]% 右腿[2 1];[21 9];[9 10];% 时髦的[10 11];[11 12];% 左腿[12 24];[12 25];[21 5];% 脊柱[5 6];[6 7];% 左手[7 8];[82];[8 23];[17];[17 18];[19];% 右手[19 20];[1 13];[13 14];[14 15];[15];];%提取第90帧和跟踪的身体信息。LastFrame = FramesPertrig-10;LastFrameMetadata =元数据(LastFrame);%找到跟踪体的索引。AnybodieStracked =任何(Lastframemetadata.isbodyTracked〜= 0);TrackedBodies = find(lastframemetadata.isbodytracked);%找到跟踪的骷髅数量。nbodies =长度(轨迹带);%获取履带机构的联合指数相对于颜色% 图片。colorjointindices = lastframemetadata.colorjointindices(:,:,trackedbodies);%提取第90个颜色框架。lastcolorimage = colorimg(:,::,lastframe);

查看带有骨架叠加层的RGB图像。

%标记颜色最多可达6具体。颜色= ['r';'G';'B';'C';'是';'M'];%显示RGB图像。imshow(lastcolorimage);%覆盖此RGB帧上的骨架。为了我= 1:24.为了身体= 1:nbodies x1 = [colorjodeindices(skeletonconnectionmap(i,1),1,body)colorjointindices(骨架连接图(i,2),1,body)];Y1 = [ColorJointIndices(SkeletonConnectionMap(I,1),2,Body)ColorJointInces(SkeletonConnectionMap(I,2),2,Body)];线(x1,y1,'行宽',1.5,'linestyle'' - ''标记''+''颜色',颜色(body));结尾抓住;结尾抓住离开;