ImageVerifierCode 换一换
格式:DOCX , 页数:7 ,大小:32.21KB ,
资源ID:423457      下载积分:5 金币
已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  
下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(我们来说说景深数据Depth Data,这是Kinect的Depth.docx)为本站会员(peixunshi0)主动上传,三一文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一文库(发送邮件至doc331@126.com或直接QQ联系客服),我们立即给予删除!

我们来说说景深数据Depth Data,这是Kinect的Depth.docx

1、我位来说说景深数iKDepthData,这是KineCt的DePthCamera为我们供应的全新功能,以往的技术只能郎功过图像识别未完成的一些工作,我们可以借助景深来帮我们完成了.比方.前景jf1.f景的别玄,以前只健将背设设置为武屏或者绿屏,但是现在有了景深数榭,我们就可以很蒲沽地将前景物体从背兔中别尚出来.当然,须要特殊说明的是,DepthCamera技术是由以色列公司PrimeSense供应的“程序布局在这章里.我In,完成的工作特别M沽.依擀物体距离Kinea的远近,设置成不同的颜色.首先.我们要创立一个新的WPF1.:出,愿后溢颌一个Image控件:然后是MaInWindOW.xam

2、1.es中的核心代码,这局部代码。之附的代码大体一样,所以不做过多说明了,/KinectRuntimeRuntineRuntiaeni=newRuntime。;privatevoidWindow_1.oaded(objectsender,RoutedEventArgse)/UseDepthAndP1.ayerIndexandUseSke1.eta1.Trackingnui.InitIa1.ize(RuntImeOptions.UseDepthAndP1.ayerIndexRuntiticoptionseUscSkc1.eta1.Tracking);/registerforeventui.Dcp

3、thFraaeRcady-newEventHand1.er(nui-DepthFrameReady);/DepthAndP1.ayerIndexImageTypenui.DepthStream.Open(ImageStream!ype.Depth,2,ItiageReso1.ution.Reso1.utio3224,IiidgeTypetDepthAndP1.ayerIndex);privatevoidWindow-C1.oscd(objectsender,EvcntArgse)nui.Unin1.tia1.izeO;唯一须要大宗例怠的是,我们在初始化函数中传递的参数是Runtimeoptio

4、ns-UseDepthAndPIayerIndex,这表示景深传息中会包含PIayerIndex的信息,接下来,我们就爱花点时间来即用DepthAndP1.ayerIndex的实际构造.SMDepthAndPIayerIndex先来价DePthFrameReady*务处理函数,如下:voidnui-DepthFrameReady(objectsender,ImageFraffieReadyEventArgse)(/ConvertdepthInformationforapixe1.Intoco1.orinformationbyteCo1.oredBytes-Generate3Bits1.5);D

5、epthAndPIayer1.ndeximage费型的第一个bytes位包括P1.ayerIndex信息P1.ayer1.ndex最多包含六个可使他:0,没有玩家:1.玩宗1:2.玩冢2,以此类推.我们n以用下面的方法来抉得P1.ayerIndex信息:privatestaticintGetPIayerIndex(bytefirstFrame)(/returns-nop1.ayer,11stp1.ayer,2-2ndp1.ayer.return(int)fIrstFrame&7;)设WR色接卜来我们创立一个bytes数组用来存储颜色鱼.if(distance)/wearethefarthest

6、Co1.orFrameindexB1.ueIndexJ;CoIorFrameindexGreenIndex=255;co1.orFrameindexRedIndex255;)当然,我们M好是设置几个边界值,柒定义不同距禽的不【可颜色,/equa1.co1.oringforIionochromatIchistogramvarintensity=Ca1.cu1.ateIntensityFronDepth(distance);CO1.OrFrameindexB1.ueIndcx-intensity;co1.orFrameindex+GreenIndexJ=intensity;co1.orFrame(

7、inJeRedIndex)-intensity;constf1.oatMaxDepthDistance=4006;/maxva1.uereturnedconstf1.oatMinDepthDistance85;/inva1.uereturnedconstf1.oatMaxDepthDistanceOffset=MaxDepthDistance-MinOepthDistance;pub1.icstaticbyteCa1.cu1.ateIntcnsityFromcpth(intdistance)(/formu1.aforca1.cu1.atingmonochromeintensityforhist

8、ogramreturn(byte)(255-(255Math.Ma(distance-MinDepthDistancej)/(MaxDepthDistanceOffset);峨终.把全部代码放在一起我们设定的颜色值为,屋色小J900:900fJ2000.愫色、大于2000.红色代码如下,privatebyte()GencratcCo1.oredBytes(ImagoFramcImageFname)(intheight三imageFname.I三age.Height;Intwidth=ImageFrame.Image.Width;/Depthdataforeachpixe1.BytedepthD

9、ata=IiiageFraae.Image.Bits;/Co1.orFramccontainsco1.orinformationfora1.1.pixe1.sinimage/HeightWidthx4(Red,Green,B1.ue,erptybyte)Byte(Co1.orFraee=newbyteImageFrame.Image.Height*ItiageFrame.Iwagc.Width*4);/Bgr32-B1.ue,Green,Red,emptybyte/Bgra32-B1.ue1Green,Red,transparency/YoumustsettransparencyforBgra

10、as.NETdefau1.tsabyteto0-fu1.1.ytransparent/hardcoded1.ocationstoB1.ue,Green,Red(BGR)indexpositionsconstintB1.ueIndex;constintGreenIndex1;constintRedIndex=2;vardepthindex=0;for(vary-;yheight;y)(varheightoffset三yxwidth;for(varx-0;xwidth;X)(varindex=(width-1)+heightOHset)*4;/vardistance=GetDistance(dep

11、thDatadepthInde,depthDatadepthindex1);vardistance-GetDista11ceWithP1.ayerIndex(depthOatadepthindex,depthDatadepthindex1);if(distance900&distance2)Wearethefarthestco1.orFrane(indexB1.ueIndex-0;co1.orFraneindexGreenIndex;co1.orFraf1.eindex*RedIndex=255;/Co1.orap1.ayerif(GetP1.ayerIde(depthDatadepthindex)WCarethefarthestco1.orFra11eindexB1.ueIndexJ-0;co1.orFraneideGreenIndex三255;co1.orFraeinde*RedIndex=255;/jumptwobytesatatimedepthindex+=2;returnCo1.orFramc;程序的现实效果如卜列图:

宁ICP备18001539号-1