Hello @shmlex and @victorsbd,
Here you can find sample code:
Some notes about using of C# wrapper:
-
Use binaries from SDK for VS 2015. In other case you’ll have issues. See Issues with initialization and deinitialization of C# wrapper -- SOLVED for details. In the above sample project all required binaries are already included.
-
Call
Astra.Context.Initialize()
to initialize library before use. And don’t forget to callAstra.Context.Terminate()
before exit from application (without this call application will crash on exit). SeeApp.xaml.cs
in the sample code. -
To start working with sensor, call
Astra.StreamSet.Open()
. If you want to work with multiple sensors, then callAstra.StreamSet.Open("device/sensorN")
, where N is zero-based index of sensor. SeeMainWindow.xaml.cs
in the sample code. -
Then, using this opened
streamSet
create stream reader by callingstreamSet.CreateReader()
. See constructor inSensorViewModel.cs
in the sample code. -
To work with depth stream, use
streamReader.GetStream<Astra.DepthStream>()
. To work with color stream, usestreamReader.GetStream<Astra.ColorStream>()
. Etc. See constructor inSensorViewModel.cs
file in the sample code. -
Set required mode for depth (and/or) color stream using
AvailableModes
property andSetMode(mode)
method. SeeSetDepthMode()
andTrySetColorMode()
methods inSensorViewModel.cs
file in the sample code. -
Be aware that not all modes returned by
AvailableModes
are actually supported! This issue was reported here: Can't get 60 fps - #3 by andrew -
To start streaming of data call
Start()
method for appropriate steam. -
To receive frames from stream(s) you have to organize loop (it is better to do it in some background thread to keep responsibility of your UI). In this loop call
streamReader.TryOpenFrame()
and then useout frame
to access data. Don’t forget to freeframe
by callingframe.Dispose()
or by usingusing (frame)
clause. SeeBackgroundProcessingLoop()
method inSensorViewModel.cs
file in the sample code. -
Alternatively, you can call
Astra.Context.Update()
method in this loop and subscribe tostreamReader.FrameReady
event. But it is not so convenient in case of working with multiple sensors. -
Don’t forget to dispose
streamSet
andstreamReader
when you stop working with sensor. SeeDispose()
method inSensorViewModel.cs
file in the sample code.
Have fun!