【问题标题】:Vitruvius Gesture not working, System.Windows.Markup.XamlParseException维特鲁威手势不起作用,System.Windows.Markup.XamlParseException
【发布时间】:2017-04-27 00:39:06
【问题描述】:

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

https://vitruviuskinect.com/blog/

已经按照每个步骤下载了他们的示例工作代码,但他的这个错误消息会显示在下面。

Click here to see the error message Image on Visual Studio

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

严重性代码描述项目文件行抑制状态 警告 处理器架构之间存在不匹配 正在建设的项目“MSIL”和处理器架构 参考“LightBuzz.Vitruvius,版本=1.0.0.0,文化=中性, processorArchitecture=AMD64", "AMD64"。这种不匹配可能会导致运行时 失败。请考虑更改目标处理器架构 您的项目通过配置管理器,以便对齐 您的项目和参考之间的处理器架构,或采取 依赖于具有匹配处理器架构的参考 项目的目标处理器架构。测试2

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();
        }

    }
}

真的希望有人可以帮助解决这个问题!提前谢谢你。

【问题讨论】:

    标签: c# wpf kinect kinect-sdk


    【解决方案1】:

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

    您的项目和您引用的程序集必须解析为相同的“架构”。

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

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

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

    而且它只使用了对 kinect 库的 64 位风格的引用。

    <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>
    

    【讨论】:

    • 哦,谢谢!在我更改为 x64 后,它现在可以正常工作了。
    猜你喜欢
    • 2011-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多