dome:利用kinect在RGB图像上绘制骨架线

原始代码照着mathworks的一个介绍视频中的程序,码下来的,修完错误之后,终于跑起来了。最初是骨架线比RGB的人小太多了,可能因为用深度图获取的骨架线,而深度图的分辨率只有512×424,RGB有1920×1080?这样,用imresize函数把彩色图也改成512×424,确实能大小一致了,但重合度没有介绍视频中的好。后来又找到一个视频,码完之后效果挺好的,程序如下:

%% 预设
imaqhwinfo
colorVid = videoinput('kinect',1);
depthVid = videoinput('kinect',2);
triggerconfig(depthVid,'manual');
triggerconfig(colorVid,'manual');
depthVid.FramesPerTrigger = 1;
depthVid.TriggerRepeat = inf;
set(getselectedsource(depthVid),'EnableBodyTracking','on');
colorVid.FramesPerTrigger = 1;
colorVid.TriggerRepeat = inf;
%%
start(depthVid);
start(colorVid);
himg = figure;
while ishandle(himg)
    trigger(colorVid);
    trigger(depthVid);
    image = getdata(colorVid);
    [depthMap,~,depthMetadata] = getdata(depthVid);   
    
    if sum(depthMetadata.IsBodyTracked) > 0
        trackedSkeletons = find(depthMetadata.IsBodyTracked);
        skeletonJoints = depthMetadata.ColorJointIndices(:, :, trackedSkeletons);
        skeletonViewer2(skeletonJoints,image,1);%这里注意一下,img的坐标原点在左上角,而数据坐标原点在左下角?
    else
        imshow(image);
    end
end
%停止时运行这两个
%stop(colorVid);
%stop(depthVid);

其中skeletonViewer2是骨架线函数
结果:我亲爱的同学(滑稽)
在这里插入图片描述
源文件在我的github

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值