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.csin 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.csin the sample code. -
Then, using this opened
streamSetcreate stream reader by callingstreamSet.CreateReader(). See constructor inSensorViewModel.csin 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.csfile in the sample code. -
Set required mode for depth (and/or) color stream using
AvailableModesproperty andSetMode(mode)method. SeeSetDepthMode()andTrySetColorMode()methods inSensorViewModel.csfile in the sample code. -
Be aware that not all modes returned by
AvailableModesare 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 frameto access data. Don’t forget to freeframeby callingframe.Dispose()or by usingusing (frame)clause. SeeBackgroundProcessingLoop()method inSensorViewModel.csfile in the sample code. -
Alternatively, you can call
Astra.Context.Update()method in this loop and subscribe tostreamReader.FrameReadyevent. But it is not so convenient in case of working with multiple sensors. -
Don’t forget to dispose
streamSetandstreamReaderwhen you stop working with sensor. SeeDispose()method inSensorViewModel.csfile in the sample code.
Have fun!