Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm exploring the feasibility of running a C# Kinect Visual Gesture Program (something like Continuous Gesture Basics project https://github.com/angelaHillier/ContinuousGestureBasics-WPF) inside of a Docker for Windows container.

  1. Is this even theoretically possible (run C# Kinect in a Docker for Windows container?)

  2. If the answer to 1 is yes, here are some extra details:

I'm using the microsoft/dotnet-framework:4.7 image as a basis and my initial Dockerfile looks like this:

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

Build the image:

$ docker build -t kinect .

Turn on container:

$ docker run -dit --name kinectContainer kinect

Attach to a powershell session to monkey around:

$ docker exec -it kinectContainer powershell

When I attempt to run my gesture application from the Docker container I get the following error (which is expected since no Kinect SDK was installed in the container):

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

At this point, the big question is how to install the Kinect v2 SDK [KinectSDK-v2.0_1409-Setup.exe] or the Kinect v2 runtime [KinectRuntime-v2.0_1409-Setup.exe] in the container.

The installers have a EULA and according to 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)

ex.

$ & '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

The issue I ran into when I got to the underlying msi files is there is no option to run them silently using msiexec.

I've figured out that the runtime installer (Runtime installer (KinectRuntime-x64.msi) extracted from the Kinect v2 SDK) makes at least the following changes in the filesystem:

Creates a folder "Kinect" in C:\Windows\System32 and adds 3 files to System 32:

k4wcll.dll

kinect20.dll

microsoft._kinect.dll

The last three files in System32 should be the 64-bit versions (the installer appears to have x86 and x64 versions of those 3)

Replicating those changes by hand does not lead to success on the host machine let alone in the container.

It's currently unclear what other registry/system changes are occurring with the installer (and whether or not that would get us over the goal line in the Docker container)

Any ideas about how to proceed from here?

like image 846
Victor Avatar asked Dec 13 '17 16:12

Victor


People also ask

Can I run Visual Studio in a Docker container?

If you already have a project of a supported type, Visual Studio can create a Dockerfile and configure your project to run in a container.

Can I use Docker for gaming?

Docker Desktop is a perfectly serviceable way to use Docker on either MacOS or Windows, but for non-trivial use cases, it leaves much to be desired.

Can I run any application in a container?

You can run any application in Docker as long as it can be installed and executed unattended, and the base operating system supports the app. Windows Server Core runs in Docker which means you can run pretty much any server or console application in Docker.

Can we run each app in an isolated container in the Docker?

The Docker platform Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allows you to run many containers simultaneously on a given host.

Can I run Docker inside a docker container?

Here are a few use cases to run docker inside a docker container. One potential use case for docker in docker is for the CI pipeline, where you need to build and push docker images to a container registry after a successful code build.

How to mount a docker container in interactive mode?

Step 1: Start Docker container in interactive mode mounting the docker.sock as volume. We will use the official docker image. Step 2: Once you are inside the container, execute the following docker command.

What is Docker-in-Docker and how does it work?

Anything with access to the socket can send instructions to the Docker daemon, providing the ability to start containers on your host, pull images, or delete data. Docker-in-Docker via dind has historically been widely used in CI environments. It means the “inner” containers have a layer of isolation from the host.

What happens when I mount a socket in a docker container?

Mounting your host’s socket to this path means docker commands run inside the container will execute against your existing Docker daemon. This means containers created by the inner Docker will reside on your host system, alongside the Docker container itself.


1 Answers

In short no. docker on windows does not have the ability to hardware tunnel/map. on Linux, it does via the --device= option

As @VonC has stated you will need to use a Windows VM this could be Hyper-V or you can use Virtual Box then you can provide the Kinect Hardware via the Tunneling method (add/connect device), without this there would be no way for your container be that VM or not to access the hardware of the host machine with windows.

like image 107
Barkermn01 Avatar answered Oct 26 '22 16:10

Barkermn01