在VB.NET中使用Kinect SDK v1示例

时间:2012-02-23 12:44:35

标签: vb.net kinect

有谁知道我在哪里可以找到VB中新Kinect SDK的示例以及更具体的KinectExplorer示例端口?

我已经在VB here中移植了整个WPFViewers项目,但它在XAML上有错误。

1 个答案:

答案 0 :(得分:0)

.net框架和所有其他CLR语言的一个好处是,您可以非常轻松地进行翻译。

http://www.developerfusion.com/tools/convert/csharp-to-vb/

只需在这里复制你想要的代码,它就会翻译它。

KinectWindow.cs文件的示例转换:

'------------------------------------------------------------------------------
' <copyright file="KinectWindow.cs" company="Microsoft">
'     Copyright (c) Microsoft Corporation.  All rights reserved.
' </copyright>
'------------------------------------------------------------------------------

Imports System.Windows
Imports Microsoft.Kinect
Imports Microsoft.Samples.Kinect.WpfViewers
Namespace Microsoft.Samples.Kinect.KinectExplorer

    ''' <summary>
    ''' This is the core kinect window.
    ''' </summary>
    Public Class KinectWindow
        Inherits Window
        #Region "Private state"
        Private ReadOnly kinectDiagnosticViewer As KinectDiagnosticViewer
        Private m_kinect As KinectSensor
        #End Region

        Public Sub New()
            Me.kinectDiagnosticViewer = New KinectDiagnosticViewer()
            Me.kinectDiagnosticViewer.KinectColorViewer.CollectFrameRate = True
            Me.kinectDiagnosticViewer.KinectDepthViewer.CollectFrameRate = True
            Content = Me.kinectDiagnosticViewer
            Width = 1024
            Height = 600
            Title = "Kinect Explorer"
            AddHandler Me.Closed, AddressOf Me.KinectWindowClosed
        End Sub

        Public Property Kinect() As KinectSensor
            Get
                Return Me.m_kinect
            End Get

            Set
                Me.m_kinect = value
                Me.kinectDiagnosticViewer.Kinect = Me.m_kinect
            End Set
        End Property

        Public Sub StatusChanged()
            Me.kinectDiagnosticViewer.StatusChanged()
        End Sub

        Private Sub KinectWindowClosed(sender As Object, e As System.EventArgs)
            ' KinectDiagnosticViewer will call kinectSensor.Stop() so we properly release its use.
            Me.Kinect = Nothing
        End Sub
    End Class
End Namespace

至于XAML:

<kv:ImageViewer x:Class="TC.Samples.Kinect.WpfViewers.KinectSkeletonViewer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:kv="clr-namespace:TC.Samples.Kinect.WpfViewers.TC.Samples.Kinect.WpfViewers"
             d:DesignHeight="480" d:DesignWidth="640">
    <Grid>
        <kv:KinectSkeleton x:Name="skeletonCanvas1" ClipToBounds="true">
        </kv:KinectSkeleton>
        <kv:KinectSkeleton x:Name="skeletonCanvas2" ClipToBounds="true">
        </kv:KinectSkeleton>
        <kv:KinectSkeleton x:Name="skeletonCanvas3" ClipToBounds="true">
        </kv:KinectSkeleton>
        <kv:KinectSkeleton x:Name="skeletonCanvas4" ClipToBounds="true">
        </kv:KinectSkeleton>
        <kv:KinectSkeleton x:Name="skeletonCanvas5" ClipToBounds="true">
        </kv:KinectSkeleton>
        <kv:KinectSkeleton x:Name="skeletonCanvas6" ClipToBounds="true">
        </kv:KinectSkeleton>
    </Grid>
</kv:ImageViewer>