【文件属性】:
文件名称:kinect的川剧变脸
文件大小:1KB
文件格式:SLN
更新时间:2022-01-15 18:05:44
html
hello word
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Kinect;
namespace HelloKinect
{
///
/// MainWindow.xaml 的交互逻辑
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void image_Loaded(object sender, RoutedEventArgs e)
{
}
private void image_Loaded_1(object sender, RoutedEventArgs e)
{
}
int count = 0;
private KinectSensor KinectSensor = null;
private ColorFrameReader colorFrameReader = null;
private WriteableBitmap colorBitmap = null;
Body[] bodies;
MultiSourceFrameReader msfr;
this.KinectSensor = KinectSensor.GetDefault();
this.colorFrameReader = this.KinectSensor.ColorFrameSource.OpenReader();
FrameDescription colorFrameDescription = this.KinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra);
this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height,96.0,96.0, PixelFormats.Bgr32,null);
bodies = new Body[6];
msfr = KinectSensor.OpenMultiSourceFrameReader(FrameSourceType.Body|FrameSourceTypes.Color);
msfr.MultiSourceFrameReader += msfr_MultiSourceFrameArrived;
this.KinectSensor.Open();
private void msfr_MultiSourceFrameArrived(object sender,MultiSourceFrameArrivedEventArgs e)
{
MultiSourceFrame msf = e.FrameReference.AcquireFrame();
if(msf != null)
{
using (BodyFrame bodyFrame = msf.BodyFrameReference.AcquireFrame())
{
using (ColorFrame colorFrame = msf.ColorFrameReference.AcquireFrame())
{
if(bodyFrame != null && colorFrame != null)
{
FrameDescription colorFrameDescription = colorFrame.FrameDescription;
using (KinectBuffer colorBuffer = colorFrame.LockRawImageBuffer())
{
this.colorBitmap.Lock();
}
}
}
}
}
}
}