Unable to retriever frames c#

Greetings, I have been working to switch our interactive wall product over from Kinect to Astra Pro and i have run into an issue retrieving the frames from the Astra.

I am:

Issue in short:
After successfully reading 6 or 7 frames using the line _Reader.TryOpenFrame(10, out Astra.ReaderFrame frame);
I receive the following exception [quote]“astra_reader_get_imageframe: Invalid Parameter”

at Astra.ApiStatus.ThrowIfError(String functionName)\r\n
at Astra.Core.Native.Reader.TryOpenFrame(IntPtr readerHandle, Int32 timeoutMillis, NativeHandle& frameHandle)\r\n
at Astra.StreamReader.TryOpenFrame(Int32 timeoutMillis, ReaderFrame& frame)\r\n
at InteractiveSurfaceDetectionSoftware.AstraReader.BackgroundReadingLoop()
[/quote]

Issue more in-depth:
I follow the steps listed in the post linked above, start context, make readers, configure readers, etc. just as in the example. Then start a background thread with the following, wich is pretty much a copy from the example. private void BackgroundReadingLoop() { bool running = true; while (running) { try { if (_Reader.TryOpenFrame(10, out Astra.ReaderFrame frame)) { using (frame) { HandleFrame(frame); } } } catch (Astra.AstraException aex) { running = false; break; } Thread.Sleep(5); } }
Using breakpoints i can see that i get about 6 or 7 frames before the exception is thrown, it is then thrown every loop. I have commented out the content of the “HandleFrame” method to see if it mite be doing something problematic but i observed the same behavior as before. I’ve tried using the DLLs that come with the example instead of the SDK but still saw the same behavior. I also don’t see why the parameter would only be valid 6 or 7 times, i feels to me that the frame resource mite not be properly disposed of but i don’t see why that would be the case.

Additionally i have tried to use the event “StreamReader.FrameReady”, i registered a listener and placed “Astra.Context.Update();” in the loop above. This however leads to no frames being received, the event never fires. However after restoring the loop i found that the event does fires on the “TryOpenFrame” call. So it seems the event works and i have registered to it just fine but Context.Update() seems to not update the context. I don’t know if these things are related but its definitely odd to me.

I hope someone can shed some light on the matter or has some ideas.

Thanks in advance.

Which sensor are you using? Astra S, Pro, Persee?

I’m using an Astra Pro.

Problem solved.

You open a Streamset to create a reader to create depth and color streams. If you don’t save the Streamset somewhere it is garbage collected and that closes the connection to the camera. Even though you don’t use it for anything anymore you do still need it because of some hidden code.