zoukankan      html  css  js  c++  java
  • Kinect 开发 —— Hello,Kinect

    控制台输出深度数据:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Kinect;
    
    namespace HelloKinectMatrix
    {
    
        class Program
        {
            static void _kinect_DepthFrameReady(Object sender, DepthImageFrameReadyEventArgs e)
            {
                // 获取Kinect深度数据,并将深度值打印到控制台上
                using(DepthImageFrame depthFrame=e.OpenDepthImageFrame())
                {
                    if(depthFrame!=null)
                    {
                        short[] depthPixelData = new short[depthFrame.PixelDataLength];
                        depthFrame.CopyPixelDataTo(depthPixelData);
    
                        foreach (short pixel in depthPixelData)
                        {
                            Console.Write(pixel);
                        }
                    }
                }
            }
            static void Main(string[] args)
            {
    
                if (KinectSensor.KinectSensors.Count>0)
                {
                    // 设置控制台前景色
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Welcome to the Kinect Matrix ... ");
    
                    // 默认选择第一个Kinect传感器
                    KinectSensor _kinect = KinectSensor.KinectSensors[0];
    
                    _kinect.DepthStream.Enable();
                    _kinect.DepthFrameReady += new EventHandler<DepthImageFrameReadyEventArgs>(_kinect_DepthFrameReady);
                    _kinect.Start();
    
                    // 按回车键退出
                    while (Console.ReadKey().Key != ConsoleKey.Enter)
                    {
                    }
    
                    // 关闭Kinect传感器
                    _kinect.Stop();
                    Console.WriteLine("Exit the Kinect Matrix ... ");
                }
                else
                {
                    Console.WriteLine("Please check the kinect sensor ");
                }
                
            }
        }
    }

    还是对C#很不熟悉,知道每条代码的含义,但自己写不出来 —— 缺乏整体架构

  • 相关阅读:
    如何绕过chrome的弹窗拦截机制
    自我介绍
    注册页面的编写
    Roadmap学习目标
    Position
    poj2506 Tiling
    poj3278 Catch That Cow
    poj3624 Charm Bracelet
    钢条切割问题带你彻底理解动态规划
    poj1328 Radar Installation
  • 原文地址:https://www.cnblogs.com/sprint1989/p/3825444.html
Copyright © 2011-2022 走看看