Kinect 2 error with c#

Hi, I tried the new SDK with Kinect 2 and c# but I cant get it to work. The c++ samples work but unity example crashes. In my c# console app, I get System.AccessViolationException: ‘Attempted to read or write protected memory. This is often an indication that other memory is corrupt.’ on DepthSensor.Create().

I would appreciate any help
Thanks

Hi Panos,

Please advise what Unity sample do you run? Please check ‘AllModulesScene’ from NuitrackSDK.unitypackage - do you encounter the same issue?

Hi Olga

Yes I encounter the same error with AllModulesScene. Unity crashes and in crash log I get this:

Read from location 0000000000000000 caused an access violation.

Context:
RDI:    0x0000000000000000  RSI: 0x0000000000000000  RAX:   0x0000000080004002
RBX:    0x0000000080004002  RCX: 0x0000000000000000  RDX:   0x0000000000000000
RIP:    0x00007ffb5760e461  RBP: 0x00000000005fb019  SegCs: 0x0000000000000033
EFlags: 0x0000000000010282  RSP: 0x00000000005fafd0  SegSs: 0x000000000000002b
R8:     0x00000000005fae68  R9:  0x00000000005fb019  R10:   0x0000000000000000
R11:    0x0000000000000246  R12: 0x0000000000000001  R13:   0x00000000224ac300
R14:    0x00000000005fba50  R15: 0x0000000000000000


Bytes at CS:EIP:
48 8b 01 ff 50 10 85 db 0f 88 36 01 00 00 80 3d 

*** WARNING ***
Managed call stack frames will be incorrect or missing.
The Mono DLL at 'C:\Program Files\Unity\Hub\Editor\2018.2.14f1\Editor\Data\Mono\EmbedRuntime\mono.dll' does not provide out-of-process stack information support.
Upgrade to a newer version of the Mono Scripting Runtime for more detailed debug information.


Stack Trace of Crashed Thread 11440:
0x00007FFB5760E461 (SenDuck) oniDriverDisableFrameSync
0x00007FFB5760EC41 (SenDuck) oniDriverDisableFrameSync
0x00007FFB57605315 (SenDuck) oniDriverDisableFrameSync
0x00007FFB57600F74 (SenDuck) oniDriverDisableFrameSync
0x00007FFB575F54DF (SenDuck) oniDriverDisableFrameSync
0x00007FFB575F13A2 (SenDuck) oniDriverInitialize
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFB86BABDA6)
0x00007FFB86BABDA6 (OpenNI2) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFB86BAB960)
0x00007FFB86BAB960 (OpenNI2) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 0000000069709154)
0x0000000069709154 (NuitrackModule) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 0000000069A51F78)
0x0000000069A51F78 (NuitrackModule) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 0000000069701EF2)
0x0000000069701EF2 (NuitrackModule) (function-name not available)
0x000000006CBA393D (libnuitrack) nuitrack_Recenter
0x000000006CB46CF8 (libnuitrack) ZN3tdv8nuitrack8Nuitrack4initERKSs
0x000000006CB5AECC (libnuitrack) nuitrack_CreateDepthSensor
ERROR: SymGetSymFromAddr64, GetLastError: 'The specified module could not be found.' (Address: 000000003578F1FD)
ERROR: SymGetModuleInfo64, GetLastError: 'A dynamic link library (DLL) initialization routine failed.' (Address: 000000003578F1FD)
0x000000003578F1FD ((<unknown>)) (function-name not available)

This is happening to me too. Same Access Violation Exception.

I am using the C# SDK, not unity.

@panos @vpenades

Please make sure that you’ve updated both Nuitrack Runtime (to v0.24.0) and Nuitrack SDK (to v1.3.6). Please note that besides added Kinect v2 support, the driver for ASUS Xtion2 was also updated in the latest Nuitrack Runtime as the previous version was not compatible with Kinect v2.
Also take a look at 3D Sensor Known Issues for Kinect v2 in our installation instructions.
As a workaround solution, you can move libSenDuck.dll from OpenNI2/Drivers folder to any other folder if you don’t need support for ASUS Xtion2.

I have the latest versions of both SDK and runtime on x64 system. There is no libSenDuck.dll in OpenNI2/Drivers. Maybe you mean SenDuck.dll? I tried moving it but I get the same error.

I believe the problem has to do with the c# version of the SDK since the c++ samples work fine.

Yes, I meant SenDuck.dll, sorry for misleading info,
Please try to run nuitrack_csharp_sample from Nuitrack SDK. Do you encounter the same error with this sample?
If you use Windows 10, please check “Windows 10 camera, microphone, and privacy” settings: Go to “Start”, then select “Settings > Privacy > Camera”, and tick “Allow apps to access your camera”.

Yes I get the same error with nuitrack_csharp_sample. My windows settings are also ok. Actually all the other cameras (Kinect1, Astra, Astra Pro, Asus Xtion 2 and RealSense D435) work fine.

Sorry for a delayed reply.

Please provide us with your SenDuck.dll version (Properties > Details > Version).

Hi, my Senduck.dll version is 3.0.0.2

What is your Kinect SDK 2.0 version?

The kinect SDK version is v2.0_1409

Do you have OpenNI2 SDK package installed in your system? (for example, after you’ve installed LIPS SDK, ASUS Xtion SDK…)

Yes I have OpenNI2 SDK installed

  1. Is there a driver for LIPS or ASUS Xtion2 inside the OpenNI SDK?
  2. Please make sure that when you run Nuitrack, OpenNI2.dll located in %NUITRACK_HOME%/bin
  1. There is no driver for LIPS but probably there is for ASUS Xtion2 since I use it.
  2. It is

Try to move SenDuck.dll from the Drivers folder up one directory (to the OpenNI folder) (in ASUS Xtion SDK).

I updated the SDK to the latest version and now it works. I am not sure what was wrong.
The problem now is that the joints positions from Kinect are reversed compared to those of the other cameras (Real Sense, Astra, etc) and since I can’t get from the SDK which camera is used I dont know how to fix it. Is there a configuration or setting to change that?

Sorry for a delayed reply.

To mirror the image, you can either modify nuitrack.config (find the section "DepthProvider" and set "Mirror" to true) or use Nuitrack API (use the DepthSensor::setMirror method).

Hello again

We’ve updated to the last runtime version 0.27 and we’re still getting random crashes.

Usually, when we run NuiTrack + Kinect, it crashes a few seconds after it started up… we do get several depth frames, and it crashes shortly after receiving some skeletons.

When I say “crash” what happens is that the application suddenly exits without any error.

This is probably happening because at some point within the runtime there’s a problem, but instead of propagating the exception or the error to the C# wrapper, the runtime is probably writing the error to the console (which is invisible to c#) and then doing an application exit.