zoukankan      html  css  js  c++  java
  • kinect学习笔记(三)——深度数据的提取

    一、创建Console工程

    image

    二、添加kinect引用

    image

    里面用引用,打开后

    image

    选择然后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);
            
                        }
                    }
                }
            }
    
    
        }
    }

    四、效果图

    image

  • 相关阅读:
    在ACCESS中LIKE的用法
    pip 在windows下的更新升级
    NAS、SAN、DAS 说明
    RAID 工作模式
    Linux mail 邮件发送
    Linux 邮件服务搭建
    HA 脑裂原理
    Tomcat 工作原理
    Nagios 工作原理
    Nginx 工作原理
  • 原文地址:https://www.cnblogs.com/BlueMountain-HaggenDazs/p/4072593.html
Copyright © 2011-2022 走看看