本文档为个人博客文档系统的备份版本、作者:小游、作者博客:点击访问
用visual studio(我用的是2020版本)新建一个窗体应用
自己取一个名字,然后新建窗体应用
然后单击解决方案,在引用哪里添加引用(选择kinect)
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-dUgKTWj1-1608946082009)(https://img.xiaoyou66.com/images/2020/04/02/O2bO.png)]
我们只需要创建一个图片就可以了
使用插件
因为后面参考教程发现好像没用,所以就打算直接看一下源码了。。。
比如一个标准的色彩传感器的源码
//------------------------------------------------------------------------------
// <copyright file="MainWindow.xaml.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Samples.Kinect.ColorBasics
{
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Kinect;
/// <summary>
/// Interaction logic for MainWindow
/// </summary>
public partial class MainWindow : Window, INotifyPropertyChanged
{
/// <summary>
/// Active Kinect sensor
/// </summary>
private KinectSensor kinectSensor = null;
/// <summary>
/// Reader for color frames
/// </summary>
private ColorFrameReader colorFrameReader = null;
/// <summary>
/// Bitmap to display
/// </summary>
private WriteableBitmap colorBitmap = null;
/// <summary>
/// Current status text to display
/// </summary>
private string statusText = null;
/// <summary>
/// Initializes a new instance of the MainWindow class.
/// </summary>
public MainWindow()
{
//获取kinect对象
this.kinectSensor = KinectSensor.GetDefault();
//打开色彩传感器
this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader();
// 颜色处理器函数(相当于处理函数)
/**
* 这个+=是c#的委托函数,多播委托相当于可以委托多个函数
*/
this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived;
// create the colorFrameDescription from the ColorFrameSource using Bgra format
//这个是创建一个彩色影像数据流
FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra);
// 创建一个bitmap对象用于显示色彩
this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);
// set IsAvailableChanged event notifier
//当状态改变的时候调用事件
this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;
// open the sensor
//打开传感器
this