大年30,祝所有开发伙伴新春快乐。

天天翻墙, 叹国内学习成本太高

看到一篇台湾 kinect 电机控制, 赞

using Microsoft.Kinect;
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; namespace ouyKinectServer
{ /// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// Active Kinect sensor
/// </summary>
private KinectSensor sensor;
KinectSensor s = KinectSensor.KinectSensors[]; public MainWindow()
{
InitializeComponent(); Loaded += MainWindow_Loaded;
bup.Click += bup_Click;
bzero.Click += bzero_Click;
bdown.Click += bdonw_Click;
}
//按 [往下] 鈕執行
void bdonw_Click(object sender, RoutedEventArgs e)
{
if (s.ElevationAngle - < s.MinElevationAngle)
//如果角度最小角度 大於 現在-5的角度的話
{
s.ElevationAngle = s.MinElevationAngle;
//就讓現在的角度等於最小的角度
}
else
//否則
{
s.ElevationAngle -= ;
//就繼續-5
}
txt.Text = "Angle :" + s.ElevationAngle;
//顯示目前角度在TextBox中
System.Threading.Thread.Sleep();
//每次執行角度改變時間為1秒
}
//按 [歸零] 鈕執行
void bzero_Click(object sender, RoutedEventArgs e)
{
s.ElevationAngle = ;
//角度規0
txt.Text = "Angle :" + s.ElevationAngle;
//顯示在TextBox中
}
//按 [往上] 鈕執行
void bup_Click(object sender, RoutedEventArgs e)
{
if (s.ElevationAngle + > s.MaxElevationAngle)
//如果目前角度+5大於最大角度的話
{
s.ElevationAngle = s.MaxElevationAngle;
//就讓角度等於最大角度
}
else
//否則
{
s.ElevationAngle += ;
//角度繼續+5
}
txt.Text = "Angle :" + s.ElevationAngle;
//顯示在TextBox中
System.Threading.Thread.Sleep();
//每次執行角度改變時間為1秒 }
//視窗載入完成時執行
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
s.Start(); //啟動Kinect
s.ElevationAngle = ; //調整角度為0
txt.Text = "Angle :" + s.ElevationAngle; //將角度顯示在TextBox裡面
}
}
}

有兴趣的可 QQ 交流 110823447

05-11 04:03