资源简介
使用kinect控制ppt,运行程序,打开ppt即可,挥手控制,本程序基于C#和Kinect1.0开发,不支持Kinect2.0
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Kinect;
using System.Windows.Forms;
namespace zuijiandan
{
class Program
{
//初始化
static Skeleton[] frameSkeletons;
static bool isBackGestureActive;
static bool isForwardGestureActive;
static void Main(string[] args)
{
//定义摄像头1
KinectSensor kinect1 = KinectSensor.KinectSensors[0];
//打开摄像头1,关节数据流
kinect1.SkeletonStream.Enable();
frameSkeletons = new Skeleton[kinect1.SkeletonStream.frameSkeletonArrayLength];
//事件触发
kinect1.SkeletonframeReady += new EventHandlerameReadyEventArgs>(kinect1_SkeletonframeReady);
//打开kinect
kinect1.Start();
while (Console.ReadKey().Key != ConsoleKey.Spacebar)
{
}
}
static void kinect1_SkeletonframeReady(object sender SkeletonframeReadyEventArgs e)
{
using (var skeletonframe = e.OpenSkeletonframe())
{
if (skeletonframe == null)
return;
if (frameSkeletons == null ||
frameSkeletons.Length != skeletonframe.SkeletonArrayLength)
{
frameSkeletons = new Skeleton[skeletonframe.SkeletonArrayLength];
}
skeletonframe.CopySkeletonDataTo(frameSkeletons);
Skeleton closestSkeleton = (from s in frameSkeletons
where s.TrackingState == SkeletonTrackingState.Tracked &&
s.Joints[JointType.Head].TrackingState == JointTrackingState.Tracked
select s).OrderBy(s => s.Joints[JointType.Head].Position.Z)
.FirstOrDefault();
if (closestSkeleton == null)
return;
//定义头部和左右手
var head = closestSkeleton.Joints[JointType.Head];
var rightHand = closestSkeleton.Joints[JointType.HandRight];
var leftHand = closestSkeleton.Joints[JointType.HandLeft];
if (head.TrackingState != JointTrackingState.Tracked ||
rightHand.TrackingState != JointTrackingState.Tracked ||
leftHand.TrackingState != JointTrackingState.Tracked)
{
return;
}
ProcessForwardBackGesture(head rightHand leftHand);
}
}
static private void ProcessForwardBackGesture(Joint head Joint rightHand Joint leftHand)
{
//挥右手时,触发键盘→键
if (rightHand.Position.X > head.Position.X + 0.35)
{
if (!isBackG
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-02-21 20:58 control ppt\
目录 0 2016-02-21 20:58 control ppt\zuijiandan\
目录 0 2016-05-26 12:55 control ppt\zuijiandan\zuijiandan\
文件 876 2013-03-24 16:54 control ppt\zuijiandan\zuijiandan.sln
文件 26624 2013-03-25 13:01 control ppt\zuijiandan\zuijiandan.suo
文件 57856 2016-05-26 12:55 control ppt\zuijiandan\zuijiandan.v12.suo
目录 0 2016-02-21 20:58 control ppt\zuijiandan\zuijiandan\bin\
目录 0 2016-02-21 20:58 control ppt\zuijiandan\zuijiandan\bin\Debug\
文件 7680 2016-02-18 16:29 control ppt\zuijiandan\zuijiandan\bin\Debug\zuijiandan.exe
文件 15872 2016-02-18 16:29 control ppt\zuijiandan\zuijiandan\bin\Debug\zuijiandan.pdb
文件 24224 2016-05-26 12:48 control ppt\zuijiandan\zuijiandan\bin\Debug\zuijiandan.vshost.exe
文件 490 2013-03-18 17:00 control ppt\zuijiandan\zuijiandan\bin\Debug\zuijiandan.vshost.exe.manifest
目录 0 2016-02-21 20:58 control ppt\zuijiandan\zuijiandan\bin\Release\
文件 7168 2013-03-24 16:45 control ppt\zuijiandan\zuijiandan\bin\Release\zuijiandan.exe
文件 13824 2013-03-24 16:45 control ppt\zuijiandan\zuijiandan\bin\Release\zuijiandan.pdb
目录 0 2016-02-21 20:58 control ppt\zuijiandan\zuijiandan\obj\
目录 0 2016-02-21 20:58 control ppt\zuijiandan\zuijiandan\obj\x86\
目录 0 2016-02-21 20:58 control ppt\zuijiandan\zuijiandan\obj\x86\Debug\
文件 6818 2016-05-26 12:47 control ppt\zuijiandan\zuijiandan\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 9956 2013-03-24 18:15 control ppt\zuijiandan\zuijiandan\obj\x86\Debug\ResolveAssemblyReference.cache
目录 0 2013-03-24 16:54 control ppt\zuijiandan\zuijiandan\obj\x86\Debug\TempPE\
文件 1423 2016-05-26 12:50 control ppt\zuijiandan\zuijiandan\obj\x86\Debug\zuijiandan.csproj.FileListAbsolute.txt
文件 13093 2016-02-18 15:09 control ppt\zuijiandan\zuijiandan\obj\x86\Debug\zuijiandan.csprojResolveAssemblyReference.cache
文件 7680 2016-02-18 16:29 control ppt\zuijiandan\zuijiandan\obj\x86\Debug\zuijiandan.exe
文件 15872 2016-02-18 16:29 control ppt\zuijiandan\zuijiandan\obj\x86\Debug\zuijiandan.pdb
目录 0 2016-02-21 20:58 control ppt\zuijiandan\zuijiandan\obj\x86\Release\
文件 6027 2013-03-24 16:45 control ppt\zuijiandan\zuijiandan\obj\x86\Release\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2013-03-24 16:54 control ppt\zuijiandan\zuijiandan\obj\x86\Release\TempPE\
文件 453 2013-03-24 16:45 control ppt\zuijiandan\zuijiandan\obj\x86\Release\zuijiandan.csproj.FileListAbsolute.txt
文件 7168 2013-03-24 16:45 control ppt\zuijiandan\zuijiandan\obj\x86\Release\zuijiandan.exe
文件 13824 2013-03-24 16:45 control ppt\zuijiandan\zuijiandan\obj\x86\Release\zuijiandan.pdb
............此处省略5个文件信息
评论
共有 条评论