C# integration of nuitrack.net.dll

Hi all,

after playing around with the different examples of the SDK, I started writing an own c# application
usiing the INTEL D435 Sensor.
What I did so far:

  1. added the reference nuitrack.net.dll to the project
  2. added “using nuitrack” directive

So far everything works fine. I sticked to the exampel code

       ....
       try
        {
            Nuitrack.Init("");
        }
        catch (nuitrack.Exception exception)
        {
            Console.WriteLine("Can not initialize Nuitrack. Exception: ", exception);
        }

         _depthSensor = DepthSensor.Create();
        _depthSensor.SetMirror(false);

          _depthSensor.OnUpdateEvent += onDepthSensorUpdate;

         try
        {
            Nuitrack.Run();
        }
        catch (nuitrack.Exception exception)
        {
            Console.WriteLine("Can not start Nuitrack. Exception: ", exception);
        }
     }

         private void onDepthSensorUpdate(DepthFrame depthFrame)
    {
        _depthFrame = depthFrame;
    }

Code Complies and I see in the Output:

DepthProviderManager: AstraProPerseeDepthProvider can’t create RGB Stream (VideoCapture device ID is not valid)
DepthProviderManager: Couldn’t open device ( DeviceOpen using default: no devices found
)
DepthProviderManager: Can not create OpenNI depth generator (OpenNI Status: Can’t create any node of the requested type!)

I also see that the sensor starts working.
But the “onDepthSensorUpdate” function is never called. ( I see that through breakpoint in the function)

What do I miss to make it work?

Thanks in advance.

Best regards,
Björn

Ok so after some more digging I think it´s somehow related to the fact that I´m using a C# WPF Project.
the code below compiles and starts the sensor but it never calls “onDepthSensorUpdate” the Eventhandler

using System;
using System.Windows;
using System.Runtime.InteropServices;
using System.Threading;
using nuitrack;
using nuitrack.issues;

namespace NuitrackTest
{

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    private DepthSensor _depthSensor;
    private ColorSensor _colorSensor;
    private UserTracker _userTracker;
    private SkeletonTracker _skeletonTracker;
    private GestureRecognizer _gestureRecognizer;
    private HandTracker _handTracker;

    private DepthFrame _depthFrame;
    private SkeletonData _skeletonData;
    private HandTrackerData _handTrackerData;
    private IssuesData _issuesData = null;


    public MainWindow()
    {
        //InitializeComponent();

        //Sensor sx = new Sensor();
        //sx.Start();
        try
        {
            Nuitrack.Init("C:/nuitrack/data/nuitrack.config");
        }
        catch (nuitrack.Exception exception)
        {
            Console.WriteLine("Can not initialize Nuitrack. Exception: ", exception);
        }

        //Thread.Sleep(1000);

        //// Create and setup all required modules
        _depthSensor = DepthSensor.Create();
        _depthSensor.SetMirror(false);

        _colorSensor = ColorSensor.Create();
        _userTracker = UserTracker.Create();
        _skeletonTracker = SkeletonTracker.Create();
        _handTracker = HandTracker.Create();
        _gestureRecognizer = GestureRecognizer.Create();

        // Add module event handlers
        _depthSensor.OnUpdateEvent += onDepthSensorUpdate;
        //_colorSensor.OnUpdateEvent += onColorSensorUpdate;
        //_userTracker.OnUpdateEvent += onUserTrackerUpdate;
        //_skeletonTracker.OnSkeletonUpdateEvent += onSkeletonUpdate;
        //_handTracker.OnUpdateEvent += onHandTrackerUpdate;
        //_gestureRecognizer.OnNewGesturesEvent += onNewGestures;

        // Add an event handler for the IssueUpdate event 
        Nuitrack.onIssueUpdateEvent += onIssueDataUpdate;

        // Create and configure the Bitmap object according to the depth sensor output mode
        OutputMode mode = _depthSensor.GetOutputMode();


        // Run Nuitrack. This starts sensor data processing.
        try
        {
            Nuitrack.Run();
        }
        catch (nuitrack.Exception exception)
        {
            Console.WriteLine("Can not start Nuitrack. Exception: ", exception);
        }
    }


    // Nuitrack depth sensor module data update callback
    private void onDepthSensorUpdate(DepthFrame depthFrame)
    {
        _depthFrame = depthFrame;
    }

    private void onIssueDataUpdate(IssuesData issuesData)
    {
        _issuesData = issuesData;
    }

 }
}

Can anyone confirm this?

Best regards,
Björn

Hi Björn,

You have to call Nuitrack.Update method in the main loop of your application. Please take a look at OnPaint method in nuitrack_csharp_sample.

Also, if you installed Nuitrack, you don’t have to specify the path to nuitrack.config file in Nuitrack.Init, otherwise you’ll have to modify nuitrack.config file. Therefore, please use Nuitrack.Init() for Nuitrack initialization.

Hi Olga,

thanks for the reply. Now it works.

Best regards,
Björn