维特鲁威手势无效,System.Windows.Markup.XamlParseException

Vitruvius Gesture not working, System.Windows.Markup.XamlParseException

你好,我最近遇到了 vitruvius,想在一个 wpf 项目上实现他们的插件以使用 kinect 手势,但甚至无法使用他们的教程,如下所示。

https://vitruviuskinect.com/blog/

已按照每个步骤并下载了他们的示例工作代码,但他的错误消息如下所示。

Click here to see the error message Image on Visual Studio

完整的错误消息如下所示。

Severity Code Description Project File Line Suppression State Warning There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "LightBuzz.Vitruvius, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. test2

写在MainWindow.xaml.cs文件中的代码

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;
using LightBuzz.Vitruvius;


namespace test2
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        KinectSensor _sensor;
        MultiSourceFrameReader _reader;
        GestureController _gestureController;


        public MainWindow()
        {
            InitializeComponent();

            _sensor = KinectSensor.GetDefault();

            if (_sensor != null)
            {
                _sensor.Open();

                _reader = _sensor.OpenMultiSourceFrameReader( FrameSourceTypes.Body);
                _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;

                _gestureController = new GestureController();
                _gestureController.GestureRecognized += GestureController_GestureRecognized;
            }


        }



        void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
        {
            var reference = e.FrameReference.AcquireFrame();



            // Body
            using (var frame = reference.BodyFrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    Body body = frame.Bodies().Closest();

                    if (body != null)
                    {
                        _gestureController.Update(body);
                    }
                }
            }
        }

        void GestureController_GestureRecognized(object sender, GestureEventArgs e)
        {
            lbGesture.Content = e.GestureType.ToString();
        }

    }
}

真心希望有人能帮忙解决这个问题!先谢谢你了。

您正在尝试使用为 x64 编译的程序集(或者更确切地说是告诉您从 MSIL 生成 64 位代码)...但是您的应用程序很可能是针对 x86...(或在 Windows 的 32 位版本上使用 AnyCPU 和你的 运行。

您的项目和您引用的程序集必须解析为相同的 "architecture"。

查看 github 上的项目代码,项目文件似乎已被编辑为明确设置 64 位引用。这意味着,只有当您在 64 位机器上并且在您的项目中使用 AnyCPU 或 x64 作为平台类型时,它才会起作用。

看看有人如何更改此 x86 配置以使用 x64。

  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    <PlatformTarget>x64</PlatformTarget>
    <OutputPath>bin\x86\Release\</OutputPath>
  </PropertyGroup>

并且它仅使用对 64 位风格的 kinect 库的引用。

<Reference Include="Microsoft.Kinect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64">

如果您想要一个 32 位的应用程序,那么您需要使用 x86 作为平台类型,并且您需要更改该引用以使其成为 32 位。

参见:How do I fix the Visual Studio compile error, "mismatch between processor architecture"?

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
    <PlatformTarget>x64</PlatformTarget>
    <DocumentationFile>bin\Release\LightBuzz.Vitruvius.XML</DocumentationFile>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <OutputPath>bin\x86\Debug\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    <PlatformTarget>x64</PlatformTarget>
    <OutputPath>bin\x86\Release\</OutputPath>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Microsoft.Kinect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=AMD64">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\..\..\Program Files\Microsoft SDKs\Kinect\v2.0-DevPreview1404\Assemblies\Microsoft.Kinect.dll</HintPath>
    </Reference>