首页 > 代码库 > kinect学习笔记(三)——深度数据的提取
kinect学习笔记(三)——深度数据的提取
一、创建Console工程
二、添加kinect引用
里面用引用,打开后
选择然后OK。
三、编写代码(有附加注释)
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Microsoft.Kinect;namespace DepthCout{ class Program { static void Main(string[] args) { if (KinectSensor.KinectSensors.Count > 0) { //设置控制台前景色 Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Welecome to the Kinect Matrix"); //默认选择使用第一个kinect传感器= = KinectSensor _kinect = KinectSensor.KinectSensors[0]; //打开红外摄像头的默认选项 _kinect.DepthStream.Enable(); //注册事件,启动Kinect _kinect.DepthFrameReady += new EventHandler<DepthImageFrameReadyEventArgs>(_kinect_DepthFrameReady); _kinect.Start(); //按回车键退出 while (Console.ReadKey().Key != ConsoleKey.Spacebar) { } //关闭kinect _kinect.Stop(); Console.WriteLine("Exit the Kinect Matrix"); } else { Console.WriteLine("Exit the Kinect Matirx"); } } static void _kinect_DepthFrameReady(object sender,DepthImageFrameReadyEventArgs e) { //获取kinect摄像头的深度数据,然后打印到console上 using(DepthImageFrame depthFrame = e.OpenDepthImageFrame()) { if(depthFrame!=null) { short[] depthPixelDate = new short[depthFrame.PixelDataLength]; depthFrame.CopyPixelDataTo(depthPixelDate); foreach(short pixel in depthPixelDate) { Console.Write(pixel); } } } } }}
四、效果图
kinect学习笔记(三)——深度数据的提取
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。