是否可以在 Docker 容器中 运行 Kinect V2?

Is it possible to run Kinect V2 inside a Docker container?

我正在探索 运行C# Kinect 视觉手势程序的可行性 (something like Continuous Gesture Basics project https://github.com/angelaHillier/ContinuousGestureBasics-WPF) inside of a Docker for Windows container.

  1. 这在理论上是否可行(运行 C# Kinect in a Docker for Windows container?)

  2. 如果对 1 的回答是肯定的,这里有一些额外的细节:

我使用 microsoft/dotnet-framework:4.7 图像作为基础,我的初始 Docker 文件如下所示:

FROM microsoft/dotnet-framework:4.7
ADD . /home/gesture
WORKDIR /home/gesture

构建图像:

$ docker build -t kinect .

开启容器:

$ docker run -dit --name kinectContainer kinect

附加到 powershell 会话以四处游荡:

$ docker exec -it kinectContainer powershell

当我尝试从 Docker 容器 运行 我的手势应用程序时,我收到以下错误(这是预期的,因为容器中没有安装 Kinect SDK):

Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'Microsoft.Kinect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenc
ies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058) ---> System.BadImageFormatExcep
tion: Cannot load a reference assembly for execution.                                           erable program. Check the spelling of the name, or if a path was included, verify that the path
   --- End of inner exception stack trace ---
   at GestureDetector.GestureDetectorApp..ctor()

此时,最大的问题是如何在容器中安装Kinect v2 SDK [KinectSDK-v2.0_1409-Setup.exe] or the Kinect v2 runtime [KinectRuntime-v2.0_1409-Setup.exe]

安装程序有 EULA 并根据 some clever University of Wisconsin folks, there is a technique to to extract installers using Wix's dark.exe decompiler(https://social.msdn.microsoft.com/Forums/en-US/a5b04520-e437-48e3-ba22-e2cdb46b4d62/silent-install-installation-instructions?forum=kinectsdk)

例如。

$ & 'C:\Program Files (x86)\WiX Toolset v3.11\bin\dark.exe' C:\installerwork\KinectRuntime-v2.0_1409-Setup.exe -x c:\installerwork\kinect_sdk_installersfiles

当我到达底层 msi 文件时,我 运行 遇到的问题是没有选项可以 运行 使用 msiexec 静默地处理它们。

我发现 运行time 安装程序(从 Kinect v2 SDK 中提取的运行时安装程序 (KinectRuntime-x64.msi))至少对文件系统进行了以下更改:

在 C:"Kinect" 中创建文件夹 \Windows\System32 并将 3 个文件添加到 System 32:

k4wcll.dll

kinect20.dll

microsoft._kinect.dll

System32 中的最后三个文件应该是 64 位版本(安装程序似乎有这 3 个的 x86 和 x64 版本)

手动复制这些更改不会在主机上取得成功,更不用说在容器中了。

目前尚不清楚安装程序还发生了哪些其他 registry/system 更改(以及这是否会让我们超过 Docker 容器中的目标线)

关于如何从这里开始的任何想法?

另一种方法是尝试在 Windows 服务器 VM 中安装 Kinetic,并检测所述安装带来的确切变化。

参见例如“How can I find out what modifications a program’s installer makes?" and a tool like ZSoft Uninstaller 2.5

一旦您准确确定 files/registry/variables 受安装过程的影响,您可以将其复制到 Dockerfile 中。

简而言之,没有。 docker 在 windows 上没有硬件 tunnel/map 的能力。在 Linux 上,它通过 --device= 选项

正如@VonC 所述,您需要使用 Windows VM,这可能是 Hyper-V,或者您可以使用 Virtual Box,然后您可以通过隧道方法提供 Kinect 硬件(add/connect 设备),如果没有这个,你的容器将无法使用 windows.

访问主机的硬件。