本文整理汇总了C#中Microsoft.Kinect.KinectSensor类的典型用法代码示例。如果您正苦于以下问题:C# KinectSensor类的具体用法?C# KinectSensor怎么用?C# KinectSensor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KinectSensor类属于Microsoft.Kinect命名空间,在下文中一共展示了KinectSensor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Form1
public Form1()
{
InitializeComponent();
outputDevice.Open();
try
{
if (KinectSensor.KinectSensors.Count == 0)
{
throw new Exception("Kinectが接続されていません");
}
// Kinectインスタンスを取得する
kinect = KinectSensor.KinectSensors[0];
// すべてのフレーム更新通知をもらう
kinect.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(kinect_AllFramesReady);
// Color,Depth,Skeletonを有効にする
kinect.SkeletonStream.Enable();
// Kinectの動作を開始する
kinect.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
Close();
}
}
开发者ID:haru2036,项目名称:laboyouthKinect,代码行数:29,代码来源:Form1.cs
示例2: KinectControl
public KinectControl(HoverButton kinectButton, double layoutHeight, double layoutWidth, List<Button> buttons, TextBox debugBox = null)
{
_kinectButton = kinectButton;
_layoutHeight = layoutHeight;
_layoutWidth = layoutWidth;
_buttons = buttons;
_debugBox = debugBox;
_kinect = KinectSensor.KinectSensors.FirstOrDefault();
if (_kinect != null)
{
_kinect.Start();
_kinect.ColorStream.Enable();
_kinect.SkeletonStream.Enable(new TransformSmoothParameters
{
Smoothing = 0.7f,
Correction = 0.1f,
Prediction = 0.1f,
JitterRadius = 0.05f,
MaxDeviationRadius = 0.05f
});
_kinect.SkeletonFrameReady += kinect_SkeletonFrameReady;
}
_activeRecognizer = CreateRecognizer();
_kinectButton.Click += KinectButton_Click;
}
开发者ID:rudylee,项目名称:WpfApp,代码行数:30,代码来源:KinectControl.cs
示例3: KinectDance
public KinectDance(double layoutHeight, double layoutWidth, List<TextBlock> menus, Style mouseOverStyle, Border menuBorder,TextBox debugBox = null)
{
_layoutHeight = layoutHeight;
_layoutWidth = layoutWidth;
_debugBox = debugBox;
_menus = menus;
_menuBorder = menuBorder;
_mouseOverStyle = mouseOverStyle;
_kinect = KinectSensor.KinectSensors.FirstOrDefault();
if (_kinect == null) return;
//_kinect.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
_kinect.Start();
_kinect.ColorStream.Enable();
_kinect.SkeletonStream.Enable(new TransformSmoothParameters
{
Smoothing = 0.7f,
Correction = 0.3f,
Prediction = 0.4f,
JitterRadius = 0.5f,
MaxDeviationRadius = 0.5f
});
_kinect.SkeletonFrameReady += kinect_SkeletonFrameReady;
}
开发者ID:rudylee,项目名称:WpfApp,代码行数:27,代码来源:KinectDance.cs
示例4: startKinect
private void startKinect()
{
if (KinectSensor.KinectSensors.Count > 0)
{
// Choose the first Kinect device
kinect = KinectSensor.KinectSensors[0];
if (kinect == null)
return;
kinect.ColorStream.Enable();
var tsp = new TransformSmoothParameters
{
Smoothing = 0.5f,
Correction = 0.5f,
Prediction = 0.5f,
JitterRadius = 0.05f,
MaxDeviationRadius = 0.04f
};
kinect.SkeletonStream.Enable(tsp);
// Start skeleton tracking
//kinect.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(kinect_ColorFrameReady);
//kinect.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady);
// Start Kinect device
kinect.Start();
}
else
{
MessageBox.Show("No Kinect Device found.");
}
}
开发者ID:BilldBird,项目名称:Kinect_Fitness,代码行数:33,代码来源:logout.xaml.cs
示例5: connexion_kinect
public KinectSensor connexion_kinect()
{
foreach (var potentialSensor in KinectSensor.KinectSensors)
{
if (potentialSensor.Status == KinectStatus.Connected)
{
sensor = potentialSensor;
}
}
if (null != sensor)
{
// Turn on the skeleton stream to receive skeleton frames
sensor.SkeletonStream.Enable();
// Start the sensor!
try
{
sensor.Start();
}
catch (IOException)
{
return sensor = null;
}
}
return sensor;
}
开发者ID:antoinedelia,项目名称:Alpha-Avina,代码行数:28,代码来源:Connexion.cs
示例6: KinectHelper
private KinectHelper(TransformSmoothParameters tsp, bool near = false,
ColorImageFormat colorFormat = ColorImageFormat.RgbResolution1280x960Fps12,
DepthImageFormat depthFormat = DepthImageFormat.Resolution640x480Fps30)
{
_kinectSensor = KinectSensor.KinectSensors.FirstOrDefault(s => s.Status == KinectStatus.Connected);
if (_kinectSensor == null)
{
throw new Exception("No Kinect-Sensor found.");
}
if (near)
{
_kinectSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
_kinectSensor.DepthStream.Range = DepthRange.Near;
_kinectSensor.SkeletonStream.EnableTrackingInNearRange = true;
}
DepthImageFormat = depthFormat;
ColorImageFormat = colorFormat;
_kinectSensor.SkeletonStream.Enable(tsp);
_kinectSensor.ColorStream.Enable(colorFormat);
_kinectSensor.DepthStream.Enable(depthFormat);
_kinectSensor.AllFramesReady += AllFramesReady;
_kinectSensor.Start();
_faceTracker = new FaceTracker(_kinectSensor);
}
开发者ID:rechc,项目名称:KinectMiniApps,代码行数:28,代码来源:KinectHelper.cs
示例7: setupKinect
public int setupKinect(Model mod, Image img)
{
theModel = mod;
theImage = img;
foreach (var potentialSensor in KinectSensor.KinectSensors)
{
if (potentialSensor.Status == KinectStatus.Connected)
{
this.sensor = potentialSensor;
this.foundSensor = true;
break;
}
}
if (this.foundSensor == false)
{
return -1;
}
this.setupSkeleton();
this.setupColor();
this.setupDepth();
this.sensor.Start();
this.setupAudio();
this.sensor.AllFramesReady += sensor_AllFramesReady;
return 0;
}
开发者ID:jgluck,项目名称:KineChroma,代码行数:29,代码来源:KinectThinker.cs
示例8: Start_Click
private void Start_Click(object sender, RoutedEventArgs e)
{
if (this.StartStopButton.Content.ToString() == ButtonStartText)
{
if (KinectSensor.KinectSensors.Any())
{
KinectSensor.KinectSensors.StatusChanged += (o, args) =>
{
this.Status.Content = args.Status.ToString();
};
sensor = KinectSensor.KinectSensors.First();
}
sensor.Start();
sensor.ElevationAngle = 0;
sensor.ColorStream.Enable();
sensor.DepthStream.Enable();
sensor.SkeletonStream.Enable();
sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Default; // Default is standing
sensor.AllFramesReady += sensorAllFramesReady;
this.ConnectionID.Content = sensor.DeviceConnectionId;
this.StartStopButton.Content = ButtonStopText;
}
else
{
if (sensor != null && sensor.IsRunning)
{
sensor.Stop();
StartStopButton.Content = ButtonStartText;
}
}
}
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:35,代码来源:MainWindow.xaml.cs
示例9: Cage4_Loaded
void Cage4_Loaded(object sender, RoutedEventArgs e)
{
foreach (var potentialSensor in KinectSensor.KinectSensors)
{
if (potentialSensor.Status == KinectStatus.Connected)
{
this.sensor = potentialSensor;
break;
}
}
if (null != this.sensor)
{
this.sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
this.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
this.colorPixels = new byte[this.sensor.ColorStream.FramePixelDataLength];
this.colorBitmap = new WriteableBitmap(this.sensor.ColorStream.FrameWidth, this.sensor.ColorStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
this.cimg_cage4.Source = this.colorBitmap;
this.sensor.AllFramesReady += this.sensor_AllFramesReady;
try
{
this.sensor.Start();
}
catch (IOException)
{
//this.sensor = null;
}
}
}
开发者ID:kadron,项目名称:rat-trek,代码行数:30,代码来源:Cage4.xaml.cs
示例10: MainWindow
public MainWindow()
{
InitializeComponent();
try {
// 利用可能なKinectを探す
foreach ( var k in KinectSensor.KinectSensors ) {
if ( k.Status == KinectStatus.Connected ) {
kinect = k;
break;
}
}
if ( kinect == null ) {
throw new Exception( "利用可能なKinectがありません" );
}
// Colorを有効にする
kinect.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>( kinect_ColorFrameReady );
kinect.ColorStream.Enable( ColorImageFormat.RgbResolution640x480Fps30 );
// Kinectの動作を開始する
kinect.Start();
}
catch ( Exception ex ) {
MessageBox.Show( ex.Message );
Close();
}
}
开发者ID:kaorun55,项目名称:KinectSdkIntroduction,代码行数:28,代码来源:MainWindow.xaml.cs
示例11: KinectCoreV2
public KinectCoreV2(ref KinectBase.MasterSettings settings, bool isGUILaunched, int kinectNumber)
{
masterSettings = settings;
dynamic temp = masterSettings.kinectOptionsList[kinectNumber];
masterKinectSettings = (KinectV2Settings)temp;
//TODO: Update this to open a specific Kinect v2, if the SDK is ever updated to support multiple on one machine
kinect = KinectSensor.GetDefault();
kinectID = kinectNumber;
uint tempC = kinect.ColorFrameSource.FrameDescription.LengthInPixels;
uint tempD = kinect.DepthFrameSource.FrameDescription.LengthInPixels;
uint tempI = kinect.InfraredFrameSource.FrameDescription.LengthInPixels;
colorImagePool = new KinectBase.ObjectPool<byte[]>(() => new byte[tempC * 4]);
depthImagePool = new KinectBase.ObjectPool<byte[]>(() => new byte[tempD * 4]);
irImagePool = new KinectBase.ObjectPool<byte[]>(() => new byte[tempI * sizeof(UInt16)]);
if (isGUILaunched)
{
isGUI = true;
LaunchKinect();
}
else
{
launchKinectDelegate kinectDelegate = LaunchKinect;
IAsyncResult result = kinectDelegate.BeginInvoke(null, null);
kinectDelegate.EndInvoke(result); //Even though this is blocking, the events should be on a different thread now.
}
}
开发者ID:vancegroup,项目名称:KVR,代码行数:29,代码来源:KinectV2Core.cs
示例12: DiscoverKinectSensor
private void DiscoverKinectSensor()
{
if (this._Kinect != null && this._Kinect.Status != KinectStatus.Connected)
{
// If the sensor is no longer connected, we need to discover a new one.
this._Kinect = null;
}
if (this._Kinect == null)
{
//Find the first connected sensor
this._Kinect = KinectSensor.KinectSensors.FirstOrDefault(x => x.Status == KinectStatus.Connected);
if (this._Kinect != null)
{
//Initialize the found sensor
this._Kinect.ColorStream.Enable();
this._Kinect.Start();
ColorImageStream colorSteam = this._Kinect.ColorStream;
this._ColorImageBitmap = new WriteableBitmap(colorSteam.FrameWidth,
colorSteam.FrameHeight,
96, 96, PixelFormats.Bgr32,
null);
this._ColorImageBitmapRect = new Int32Rect(0, 0, colorSteam.FrameWidth,
colorSteam.FrameHeight);
this._ColorImageStride = colorSteam.FrameWidth *
colorSteam.FrameBytesPerPixel;
this.ColorImageElement.Source = this._ColorImageBitmap;
this._ColorImagePixelData = new byte[colorSteam.FramePixelDataLength];
}
}
}
开发者ID:kulturberikare,项目名称:RUNKinect,代码行数:33,代码来源:MainWindow.xaml.cs
示例13: initialize
public void initialize( int elevationAngle = 0 )
{
try { kinectSensor = KinectSensor.KinectSensors[0]; }
catch (Exception e)
{
Console.WriteLine("kinect not detected, continuing with kinect disabled {0}",e);
return;
}
if (kinectSensor == null) {
return;
}
// limits elevation angle to keep the motors from trying too extreme an angle
if (elevationAngle >= 26 )
{
elevationAngle = 26;
}
else if (elevationAngle <= -26)
{
elevationAngle = -26;
}
// Only initializes Skeletal Tracking
kinectSensor.SkeletonStream.Enable();
// set a call back function to process skeleton data
kinectSensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinectSkeletonFrameReadyCallback);
kinectSensor.Start();
kinectSensor.ElevationAngle = elevationAngle;
}
开发者ID:suntinwong,项目名称:mypong,代码行数:31,代码来源:Kinect.cs
示例14: MathiasCore
/// <summary>
/// Simply a empty Constructor
/// </summary>
public MathiasCore()
{
CONNECTED = false;
KinectAudio = new KinectAudioController();
kinect = KinectSensor.GetDefault();
dbManager = new DBManager();
}
开发者ID:MATHIAS15,项目名称:MATHIAS-CORE,代码行数:10,代码来源:MathiasCore.cs
示例15: ConvertDepthColor
/// <summary>
/// 距離データをカラー画像に変換する
/// </summary>
/// <param name="kinect"></param>
/// <param name="depthFrame"></param>
/// <returns></returns>
private byte[] ConvertDepthColor( KinectSensor kinect, DepthImageFrame depthFrame )
{
ColorImageStream colorStream = kinect.ColorStream;
DepthImageStream depthStream = kinect.DepthStream;
// 距離カメラのピクセルごとのデータを取得する
short[] depthPixel = new short[depthFrame.PixelDataLength];
depthFrame.CopyPixelDataTo( depthPixel );
// 距離カメラの座標に対応するRGBカメラの座標を取得する(座標合わせ)
ColorImagePoint[] colorPoint = new ColorImagePoint[depthFrame.PixelDataLength];
kinect.MapDepthFrameToColorFrame( depthStream.Format, depthPixel,
colorStream.Format, colorPoint );
byte[] depthColor = new byte[depthFrame.PixelDataLength * Bgr32BytesPerPixel];
for ( int index = 0; index < depthPixel.Length; index++ ) {
// 距離カメラのデータから、プレイヤーIDと距離を取得する
int player = depthPixel[index] & DepthImageFrame.PlayerIndexBitmask;
int distance = depthPixel[index] >> DepthImageFrame.PlayerIndexBitmaskWidth;
// 変換した結果が、フレームサイズを超えることがあるため、小さいほうを使う
int x = Math.Min( colorPoint[index].X, colorStream.FrameWidth - 1 );
int y = Math.Min( colorPoint[index].Y, colorStream.FrameHeight - 1 );
int colorIndex = ((y * depthFrame.Width) + x) * Bgr32BytesPerPixel;
if ( player != 0 ) {
depthColor[colorIndex] = 255;
depthColor[colorIndex + 1] = 255;
depthColor[colorIndex + 2] = 255;
}
else {
// サポート外 0-40cm
if ( distance == depthStream.UnknownDepth ) {
depthColor[colorIndex] = 0;
depthColor[colorIndex + 1] = 0;
depthColor[colorIndex + 2] = 255;
}
// 近すぎ 40cm-80cm(default mode)
else if ( distance == depthStream.TooNearDepth ) {
depthColor[colorIndex] = 0;
depthColor[colorIndex + 1] = 255;
depthColor[colorIndex + 2] = 0;
}
// 遠すぎ 3m(Near),4m(Default)-8m
else if ( distance == depthStream.TooFarDepth ) {
depthColor[colorIndex] = 255;
depthColor[colorIndex + 1] = 0;
depthColor[colorIndex + 2] = 0;
}
// 有効な距離データ
else {
depthColor[colorIndex] = 0;
depthColor[colorIndex + 1] = 255;
depthColor[colorIndex + 2] = 255;
}
}
}
return depthColor;
}
开发者ID:hatsunea,项目名称:KinectSDKBook4CS,代码行数:66,代码来源:MainWindow.xaml.cs
示例16: Window_Loaded_1
private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
miKinect = KinectSensor.KinectSensors[0];
miKinect.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
miKinect.Start();
miKinect.ColorFrameReady += miKinect_ColorFrameReady;
}
开发者ID:egaleano,项目名称:Kinect,代码行数:7,代码来源:MainWindow.xaml.cs
示例17: initKinect
private void initKinect()
{
if (KinectSensor.KinectSensors.Count > 0)
kinect = KinectSensor.KinectSensors[0];
else
{
info.Content = "Pas de kinect connectée";
}
try
{
kinect.SkeletonStream.Enable();
kinect.DepthStream.Enable();
interStream = new InteractionStream(kinect, new DummyInteraction());
kinect.DepthFrameReady += KinectOnDepthFrameReady;
kinect.SkeletonFrameReady += KinectOnSkeletonFrameReady;
interStream.InteractionFrameReady += interStream_InteractionFrameReady;
kinect.Start();
}
catch(Exception e)
{
// throw e;
}
}
开发者ID:guozanhua,项目名称:Kinect-Painter,代码行数:28,代码来源:MainWindow.xaml.cs
示例18: MainWindow
public MainWindow()
{
InitializeComponent();
_sensor = KinectSensor.GetDefault();
if (_sensor != null)
{
_sensor.Open();
_bodies = new Body[_sensor.BodyFrameSource.BodyCount];
_colorReader = _sensor.ColorFrameSource.OpenReader();
_colorReader.FrameArrived += ColorReader_FrameArrived;
_bodyReader = _sensor.BodyFrameSource.OpenReader();
_bodyReader.FrameArrived += BodyReader_FrameArrived;
// 2) Initialize the face source with the desired features
_faceSource = new FaceFrameSource(_sensor, 0, FaceFrameFeatures.BoundingBoxInColorSpace |
FaceFrameFeatures.FaceEngagement |
FaceFrameFeatures.Glasses |
FaceFrameFeatures.Happy |
FaceFrameFeatures.LeftEyeClosed |
FaceFrameFeatures.MouthOpen |
FaceFrameFeatures.PointsInColorSpace |
FaceFrameFeatures.RightEyeClosed |
FaceFrameFeatures.LookingAway);
_faceReader = _faceSource.OpenReader();
_faceReader.FrameArrived += FaceReader_FrameArrived;
}
}
开发者ID:pghdotnet,项目名称:OxfordFace,代码行数:31,代码来源:MainWindow.xaml.cs
示例19: Angulo
public Angulo(KinectSensor miKinect)
{
InitializeComponent();
this.miKinect = miKinect;
angulo = miKinect.ElevationAngle;
barraAngulo.Value = angulo;
}
开发者ID:CesarGamarra,项目名称:Kinect-Android-Security-Server,代码行数:7,代码来源:Angulo.cs
示例20: Kinect
//Runtime nui;
public Kinect()
{
skeleton = new skeleton(0);
//getting first kinect
foreach (KinectSensor sensor in KinectSensor.KinectSensors)
{
if (sensor.Status == KinectStatus.Connected)
{
kinectSensor = sensor;
break;
}
}
if (kinectSensor == null)
return;
Console.WriteLine(kinectSensor.Status);
//starting kinect and enabling skeleton data stream
kinectSensor.Start();
kinectSensor.SkeletonStream.Enable();
//register event handler on skeleton fram ready event
kinectSensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(skeletonFrameReady);
}
开发者ID:blackEagle2012,项目名称:XNA-Game-project,代码行数:27,代码来源:kinect.cs
注:本文中的Microsoft.Kinect.KinectSensor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论